-
-
Save godfat/ba962fd81c03c1ddde00 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
class User < Struct.new(:enable_email, :email) | |
extend Validator | |
validate :email, v.present(:enable_email) & v.match(:email, /[^@]+@[^@]+/) | |
end | |
User.new(true, 'a@b').check |
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
ValidEmail = Validate.new do |v| | |
v.present(:enable_email) & v.match(:email, /[^@]+@[^@]+/) | |
end | |
class User < Struct.new(:enable_email, :email) | |
end | |
ValidEmail.check(User.new(true, 'a@b').to_h) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment