Sha256: 55e61d27fd575f66aba7b019d12e01f970e4e57c98f354648fdb78be061077a1
Contents?: true
Size: 517 Bytes
Versions: 9
Compression:
Stored size: 517 Bytes
Contents
I18n.load_path += Dir.glob( File.expand_path('../locales/*.{rb,yml}', __FILE__) ) class PhoneValidator < ActiveModel::EachValidator def validate_each(object, attribute, value) return if value.blank? phone = Phonie::Phone.parse(value) if phone.nil? object.errors.add(attribute, :invalid_phone_number) else formated = phone.format( phone.extension ? :default_with_extension : :default) object.send("#{attribute}=", formated) if object.respond_to?("#{attribute}=") end end end
Version data entries
9 entries across 9 versions & 1 rubygems