Class: Apes::Validators::EmailValidator

Inherits:
BaseValidator
  • Object
show all
Defined in:
lib/apes/validators.rb

Overview

Validates email.

Instance Method Summary (collapse)

Methods inherited from BaseValidator

#validate_each

Constructor Details

- (Apes::Validators::EmailValidator) initialize(options)

Creates a new validator.

Parameters:

  • options (Hash)

    The options for the validations.



91
92
93
# File 'lib/apes/validators.rb', line 91

def initialize(options)
  super(options.reverse_merge(default_message: "must be a valid email"))
end

Instance Method Details

- (Boolean) check_valid?(value)

Checks if the value is valid for this validator.

Parameters:

  • value (Object)

    The value to validate.

Returns:

  • (Boolean)

    true if the value is valid, false otherwise.



99
100
101
# File 'lib/apes/validators.rb', line 99

def check_valid?(value)
  value.blank? || UrlsParser.instance.email?(value.ensure_string)
end