lib/validates_cnpj.rb in validates_cnpj-1.1.0 vs lib/validates_cnpj.rb in validates_cnpj-1.1.1
- old
+ new
@@ -4,8 +4,9 @@
require "validates_cnpj/shoulda-matchers/require_a_valid_cnpj_matcher" if defined?(::Shoulda)
require "validates_cnpj/remarkable/require_a_valid_cnpj_matcher" if defined?(::Remarkable)
class CnpjValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
- record.errors[attribute] << I18n.t("activerecord.errors.models.#{record.class.name.downcase}.attributes.#{attribute.to_s}.invalid") unless CNPJ.new(value).valid?
+ key = :"activerecord.errors.models.#{record.class.name.downcase}.attributes.#{attribute.to_s}.invalid"
+ record.errors[attribute] << I18n.t(key, :default => :"errors.messages.invalid") unless CNPJ.new(value).valid?
end
end
\ No newline at end of file