Sha256: 64586baf28b2ccaedae6aa9c6b33c8aabc1a1dd71737b834c1a41331f2eb0c2e

Contents?: true

Size: 393 Bytes

Versions: 45

Compression:

Stored size: 393 Bytes

Contents

# An ActiveRecord validator for any email field that you would use with effective_email or otherwise
#
# validates :phone, effective_email: true

class EffectiveEmailValidator < ActiveModel::EachValidator
  PATTERN = /\A.+@.+\..+\Z/

  def validate_each(record, attribute, value)
    if value.present?
      record.errors.add(attribute, 'is invalid') unless PATTERN =~ value
    end
  end
end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
effective_form_inputs-1.1.9 app/validators/effective_email_validator.rb
effective_form_inputs-1.1.8 app/validators/effective_email_validator.rb
effective_form_inputs-1.1.7 app/validators/effective_email_validator.rb
effective_form_inputs-1.1.6 app/validators/effective_email_validator.rb
effective_form_inputs-1.1.5 app/validators/effective_email_validator.rb
effective_form_inputs-1.1.4 app/validators/effective_email_validator.rb
effective_form_inputs-1.1.3 app/validators/effective_email_validator.rb
effective_form_inputs-1.1.2 app/validators/effective_email_validator.rb
effective_form_inputs-1.1.1 app/validators/effective_email_validator.rb
effective_form_inputs-1.1.0 app/validators/effective_email_validator.rb
effective_form_inputs-1.0.9 app/validators/effective_email_validator.rb
effective_form_inputs-1.0.8 app/validators/effective_email_validator.rb
effective_form_inputs-1.0.7 app/validators/effective_email_validator.rb
effective_form_inputs-1.0.6 app/validators/effective_email_validator.rb
effective_form_inputs-1.0.5 app/validators/effective_email_validator.rb
effective_form_inputs-1.0.4 app/validators/effective_email_validator.rb
effective_form_inputs-1.0.3 app/validators/effective_email_validator.rb
effective_form_inputs-1.0.2 app/validators/effective_email_validator.rb
effective_form_inputs-1.0.1 app/validators/effective_email_validator.rb
effective_form_inputs-1.0.0 app/validators/effective_email_validator.rb