-
-
Save blelump/6ef879b3a7bae47287a5 to your computer and use it in GitHub Desktop.
This file contains 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
validation :email do | |
key(:email).required | |
end | |
validation :after_email, if: lambda { |results| results[:email]==true } do # extends the above. | |
key(:username).required | |
end | |
# block gets evaled in form instance context. | |
validation :password, if: lambda { |results| email == "john@trb.org" } do | |
key(:password).required | |
end |
This file contains 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
rule(:user_inactive, user_active?: [:email]) | |
rule(:password_invalid, password_valid?: [:email, :password]) | |
rule(:password_invalid) do | |
value(:email).user_active? & value(:email).password_valid?(value(:password)) | |
end # It doesn't work as expected since if user is inactive, then it returns false and also puts :password_invalid into errors |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment