Sha256: eadfbe43d9e727dcbf8017a1e9539e023054f0c26d3e03e1e8f527700cfb0758

Contents?: true

Size: 455 Bytes

Versions: 13

Compression:

Stored size: 455 Bytes

Contents

class HashValidator::Validator::EmailValidator < HashValidator::Validator::Base
  def initialize
    super('email')  # The name of the validator
  end

  def presence_error_message
    'is not a valid email'
  end

  def validate(key, value, validations, errors)
    unless value.is_a?(String) && value.include?("@")
      errors[key] = presence_error_message
    end
  end
end

HashValidator.append_validator(HashValidator::Validator::EmailValidator.new)

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
hash_validator-0.7.1 lib/hash_validator/validators/email_validator.rb
hash_validator-0.7.0 lib/hash_validator/validators/email_validator.rb
hash_validator-0.6.0 lib/hash_validator/validators/email_validator.rb
hash_validator-0.5.0 lib/hash_validator/validators/email_validator.rb
hash_validator-0.4.0 lib/hash_validator/validators/email_validator.rb
hash_validator-0.3.0 lib/hash_validator/validators/email_validator.rb
hash_validator-0.2.7 lib/hash_validator/validators/email_validator.rb
hash_validator-0.2.6 lib/hash_validator/validators/email_validator.rb
hash_validator-0.2.5 lib/hash_validator/validators/email_validator.rb
hash_validator-0.2.4 lib/hash_validator/validators/email_validator.rb
hash_validator-0.2.3 lib/hash_validator/validators/email_validator.rb
hash_validator-0.2.2 lib/hash_validator/validators/email_validator.rb
hash_validator-0.2.1 lib/hash_validator/validators/email_validator.rb