Sha256: 95557e0f8ac59b9c43acb07278fa8f83e677fc5753f4039a2432670763e975dc
Contents?: true
Size: 329 Bytes
Versions: 10
Compression:
Stored size: 329 Bytes
Contents
class PhoneNumberFormatValidator < ActiveModel::EachValidator def validate_each(object, attribute, value) unless value =~ /\A(\+?1( |-)?)?(\(?[0-9]{3}\)?|[0-9]{3})( |-)?([0-9]{3}( |-)?[0-9]{4})\z/ object.errors[attribute] << (options[:message] || "enter a valid 10-digit number (e.g. 587-555-5555)") end end end
Version data entries
10 entries across 10 versions & 1 rubygems