Created
July 2, 2018 11:48
-
-
Save groony/0326aa3c4cfcc8b961a1cf2728441a0b to your computer and use it in GitHub Desktop.
high level rules ex3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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