Sha256: f550e7611afa791dc9fd8889789bcefe9f7edf1bd585e81f4e1519e48977fbb5
Contents?: true
Size: 587 Bytes
Versions: 35
Compression:
Stored size: 587 Bytes
Contents
# A custom validator "email". # Doesn't really validate an email completely # It simply asserts that the email string has one (and only one) # @ (at symbol). This is mainly # to give user feedback and not to assert the e-mail validity. class EmailValidator < ActiveModel::EachValidator # Regex originated from the Devise gem REGEX = /\A[^@]+@([^@\.]+\.)+[^@\.]+\z/ def validate_each( rec, attr, value) unless value.present? && value.match( REGEX ) rec.errors.add attr, options[:message] || 'does not appear to be a valid email' end end end
Version data entries
35 entries across 35 versions & 3 rubygems