Sha256: 0f7ab721d1f0e379d69092eb6f0206e2f98e8c596971592df4c5bbec7a164d0b

Contents?: true

Size: 291 Bytes

Versions: 10

Compression:

Stored size: 291 Bytes

Contents

class EmailFormatValidator < ActiveModel::EachValidator
  def validate_each(object, attribute, value)
    unless value =~ /\A[^`@\s]+@([^@`\s\.]+\.)+[^`@\s\.]+\z/
      object.errors[attribute] << (options[:message] || "enter a valid email address (e.g. name@example.com)")
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ama_validators-0.0.13 lib/ama_validators/email_format_validator.rb
ama_validators-0.0.12 lib/ama_validators/email_format_validator.rb
ama_validators-0.0.11 lib/ama_validators/email_format_validator.rb
ama_validators-0.0.10 lib/ama_validators/email_format_validator.rb
ama_validators-0.0.9 lib/ama_validators/email_format_validator.rb
ama_validators-0.0.8 lib/ama_validators/email_format_validator.rb
ama_validators-0.0.7 lib/ama_validators/email_format_validator.rb
ama_validators-0.0.6 lib/ama_validators/email_format_validator.rb
ama_validators-0.0.5 lib/ama_validators/email_format_validator.rb
ama_validators-0.0.4 lib/ama_validators/email_format_validator.rb