dry-rb/dry-validation

Support for "validate" helper within rule blocks

Open

#679 aperta il 16 dic 2020

Vedi su GitHub
 (6 commenti) (3 reazioni) (0 assegnatari)Ruby (193 fork)github user discovery
featurehelp wanted

Metriche repository

Star
 (1421 star)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

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

Guida contributor