Sha256: 55f7de5df1f49ca7d30f6451a7c1d1e5abaebd454d7184d4451b763830b5013f

Contents?: true

Size: 283 Bytes

Versions: 3

Compression:

Stored size: 283 Bytes

Contents

# frozen_string_literal: true

class EmailValidator < ActiveModel::EachValidator
  def validate_each(obj, attribute, value)
    return if value.is_a?(String) && URI::MailTo::EMAIL_REGEXP.match?(value)

    obj.errors.add attribute, (options[:message] || "is not an email")
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
solid-process-0.3.0 lib/solid/validators/email_validator.rb
solid-process-0.2.0 lib/solid/validators/email_validator.rb
solid-process-0.1.0 lib/solid/validators/email_validator.rb