class DefraRuby::Validators::EmailValidator

Public Instance Methods

validate_each(record, attribute, value) click to toggle source
# File lib/defra_ruby/validators/email_validator.rb, line 10
def validate_each(record, attribute, value)
  return false unless value_is_present?(record, attribute, value)

  valid_format?(record, attribute, value)
end

Private Instance Methods

valid_format?(record, attribute, value) click to toggle source
# File lib/defra_ruby/validators/email_validator.rb, line 18
def valid_format?(record, attribute, value)
  # validate_email_format returns nil if the validation passes
  return true unless ValidatesEmailFormatOf.validate_email_format(value)

  add_validation_error(record, attribute, :invalid_format)
  false
end