Sha256: abdcde4c36ba1e72d44935b91bc91ac76585f4ec9db9d43abc3f69d67da9467e

Contents?: true

Size: 457 Bytes

Versions: 3

Compression:

Stored size: 457 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

3 entries across 3 versions & 1 rubygems

Version Path
hash_validator-1.1.0 lib/hash_validator/validators/email_validator.rb
hash_validator-1.0.0 lib/hash_validator/validators/email_validator.rb
hash_validator-0.8.0 lib/hash_validator/validators/email_validator.rb