Sha256: 22a7dfddcf76c42444b4f23320581b0454636e46e940fb88dbbc2e24d7468064
Contents?: true
Size: 375 Bytes
Versions: 11
Compression:
Stored size: 375 Bytes
Contents
class PhonePatternValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) if !value.blank? first_normalize value unless value.match(/^((\d){10})$/i) record.errors[attribute] << "10 digit phone number, area-code first, no country code please." end end end private def first_normalize number number.to_phone end end
Version data entries
11 entries across 11 versions & 1 rubygems