dry-rb / dry-rb/dry-validation

Support for "validate" helper within rule blocks

Open
#679 6 comments 3 reactions 0 assignees View on GitHub
feature help wanted
Dominant language
Ruby
Stars
1.4k
Forks
195
PR merge metrics
No merged PRs in 30d

Description

Support for executing predicates using `validate` method within `rule` blocks will make it much easier to apply various checks with extra conditions:

```ruby
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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.