Sha256: e6fdcc924ae6c8caa23dbd8e5f2c0a7a284fa14bf7e5e77246e71f238f32720e

Contents?: true

Size: 288 Bytes

Versions: 3

Compression:

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

3 entries across 3 versions & 1 rubygems

Version Path
ama_validators-0.0.3 lib/ama_validators/email_format_validator.rb
ama_validators-0.0.2 lib/ama_validators/email_format_validator.rb
ama_validators-0.0.1 lib/ama_validators/email_format_validator.rb