Sha256: bdd7c44190954a05c6e9744a8e902bad653ceb4f77cb82ecaab08f5461da1437
Contents?: true
Size: 703 Bytes
Versions: 1
Compression:
Stored size: 703 Bytes
Contents
# frozen_string_literal: true require 'active_model' class EmailValidator < ActiveModel::EachValidator def self.regexp(options = {}) if options[:strict_mode] ActiveSupport::Deprecation.warn( 'Strict mode has been deprecated in email_validator 2.0. To fix this warning, '\ 'remove `strict_mode: true` from your validation call.' ) end /[^\s]@[^\s]/ end def self.valid?(value, options = nil) !invalid?(value) end def self.invalid?(value, options = nil) !(value =~ regexp) end def validate_each(record, attribute, value) if self.class.invalid?(value) record.errors.add(attribute, options[:message] || :invalid) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
email_validator-2.0.0 | lib/email_validator.rb |