Sha256: cdb83bdaaa24e75e69590e2a3815435c2b0b52fe59a4fe6283cfce119acab7d7
Contents?: true
Size: 450 Bytes
Versions: 2
Compression:
Stored size: 450 Bytes
Contents
require "active_model" require "validates_telephone/telephone" class TelephoneValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) if options[:locale].nil? record.errors[attribute] << I18n.t("errors.messages.invalid") unless Telephone.new(value, :br).valid? else record.errors[attribute] << I18n.t("errors.messages.invalid") unless Telephone.new(value, options[:location]).valid? end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
validates_telephone-0.2.1 | lib/validates_telephone.rb |
validates_telephone-0.2.0 | lib/validates_telephone.rb |