Skip to content

Instantly share code, notes, and snippets.

@groony
Created July 2, 2018 09:14
Show Gist options
  • Save groony/4006b709d08b392bf620ffbc49a36300 to your computer and use it in GitHub Desktop.
Save groony/4006b709d08b392bf620ffbc49a36300 to your computer and use it in GitHub Desktop.
high level rules example
schema = Dry::Validation.Schema(Dry::Validation::Schema::Params) do
optional(:password).maybe(:str?, min_size?: 6)
optional(:identity_id).maybe(:int?)
rule(password_or_identity_id_filled: %i[password identity_id]) do |password, identity_id|
password.filled? | identity_id.filled?
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment