Sha256: 7067b4933b51f02cc746d148879dc2da4a9369f6937658c807308ccfdcde21b2

Contents?: true

Size: 369 Bytes

Versions: 10

Compression:

Stored size: 369 Bytes

Contents

# frozen_string_literal: true

class EmailValidator < BaseValidator

  REGEXP = /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i

  private

  def valid_attr?
    valid_regexp? && valid_domain?
  end

  def valid_domain?
    return true unless options.key?(:domain)

    Array(options[:domain]).any? { |domain| value.downcase.end_with?(".#{domain.downcase}") }
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
lite-validators-1.8.0 lib/lite/validators/email_validator.rb
lite-validators-1.7.2 lib/lite/validators/email_validator.rb
lite-validators-1.7.1 lib/lite/validators/email_validator.rb
lite-validators-1.7.0 lib/lite/validators/email_validator.rb
lite-validators-1.6.0 lib/lite/validators/email_validator.rb
lite-validators-1.5.0 lib/lite/validators/email_validator.rb
lite-validators-1.4.0 lib/lite/validators/email_validator.rb
lite-validators-1.3.2 lib/lite/validators/email_validator.rb
lite-validators-1.3.1 lib/lite/validators/email_validator.rb
lite-validators-1.3.0 lib/lite/validators/email_validator.rb