Sha256: ac51b62f3db21d9c789ae234c34721a19bd7a1fda9742329aa4ff3a1ecc435d1

Contents?: true

Size: 376 Bytes

Versions: 2

Compression:

Stored size: 376 Bytes

Contents

# frozen_string_literal: true

class EmailValidator < BaseValidator

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

  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

2 entries across 2 versions & 1 rubygems

Version Path
lite-validators-1.2.0 lib/lite/validators/email_validator.rb
lite-validators-1.1.2 lib/lite/validators/email_validator.rb