Sha256: 5f4d79b758e5d086a847789538e00f0996114e49631ae1adbe009a71e952f871
Contents?: true
Size: 552 Bytes
Versions: 2
Compression:
Stored size: 552 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.3 | lib/validates_phone_format_of.rb |
validates_phone_format_of-1.0.2 | lib/validates_phone_format_of.rb |