Sha256: d4302519c65f525da86a1d4bc2bcfe8d0a8454877cd8b5e8e6b7ea37b5cfcb07
Contents?: true
Size: 555 Bytes
Versions: 2
Compression:
Stored size: 555 Bytes
Contents
require 'active_model' module ValidatesPhoneFormatOf Regexp = /\A\+?[1-9]\d{1,14}\z/ end module ActiveModel module Validations class PhoneFormatValidator < EachValidator def validate_each(record, attribute, value) record.errors.add(attribute, :invalid, options.merge({:value => value})) if value.to_s !~ ValidatesPhoneFormatOf::Regexp end end module HelperMethods def validates_phone_format_of(*attr_names) validates_with PhoneFormatValidator, _merge_attributes(attr_names) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
validates_phone_format_of-1.0.5 | lib/validates_phone_format_of.rb |
validates_phone_format_of-1.0.4 | lib/validates_phone_format_of.rb |