Skip to content

Instantly share code, notes, and snippets.

@groony
Created July 2, 2018 11:48
Show Gist options
  • Save groony/0326aa3c4cfcc8b961a1cf2728441a0b to your computer and use it in GitHub Desktop.
Save groony/0326aa3c4cfcc8b961a1cf2728441a0b to your computer and use it in GitHub Desktop.
high level rules ex3
schema = Dry::Validation.Schema(Dry::Validation::Schema::Params) do
configure do
option :user
def email_confirmed?(value)
# your code
end
def authenticated?(value)
# your code
end
end
required(:email).filled(:str?)
required(:password).filled(:str?)
rule(credentials: %i[email password]) do |email, password|
password.authenticated? & (password.authenticated? > email.email_confirmed?)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment