dry-rb/dry-validation

Support for pattern-matched rules

Open

#678 opened on Dec 16, 2020

View on GitHub
 (10 comments) (5 reactions) (1 assignee)Ruby (193 forks)github user discovery
featurehelp wanted

Repository metrics

Stars
 (1,421 stars)
PR merge metrics
 (PR metrics pending)

Description

In order to make defining rules that depend on additional conditions nicer, we can have something like this:

params do
  optional(:per_page).value(:integer)
end

rule(:per_page).if(:key?).validate(gt?: 0, lteq?: 20)

See the original conversation: https://github.com/dry-rb/dry-validation/issues/540#issuecomment-744022950

Contributor guide