dry-rb/dry-validation
View on GitHubSupport for "validate" helper within rule blocks
Open
#679 opened on Dec 16, 2020
featurehelp wanted
Repository metrics
- Stars
- (1,421 stars)
- PR merge metrics
- (PR metrics pending)
Description
Support for executing predicates using validate method within rule blocks will make it much easier to apply various checks with extra conditions:
params do
optional(:per_page).filled(:integer)
end
rule(:per_page) do
if key?
key.failure("must be within 0..20 range") unless validate(gt?: 0, lteq?: 20)
end
end
See the original conversation: https://github.com/dry-rb/dry-validation/issues/678