Sha256: b9c1f412acee5adfb86f445a1fb23146f162f8fa3e065758baf4c4547b701caf
Contents?: true
Size: 557 Bytes
Versions: 1
Compression:
Stored size: 557 Bytes
Contents
require 'active_model' module ValidatesPhoneFormatOf Regexp = /\A\+\d{1,15}\z/ end module ActiveModel module Validations class PhoneFormatValidator < EachValidator def validate_each(record, attribute, value) record.errors.add(attribute, :invalid_phone, **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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
validates_phone_format_of-3.0.0 | lib/validates_phone_format_of.rb |