validates_cnpj 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/validates_cnpj/version.rb +1 -1
- data/lib/validates_cnpj.rb +2 -1
- data/spec/validates_cnpj_spec.rb +0 -1
- metadata +1 -1
data/lib/validates_cnpj.rb
CHANGED
@@ -6,6 +6,7 @@ require "validates_cnpj/remarkable/require_a_valid_cnpj_matcher" if defined?(::R
|
|
6
6
|
|
7
7
|
class CnpjValidator < ActiveModel::EachValidator
|
8
8
|
def validate_each(record, attribute, value)
|
9
|
-
|
9
|
+
key = :"activerecord.errors.models.#{record.class.name.downcase}.attributes.#{attribute.to_s}.invalid"
|
10
|
+
record.errors[attribute] << I18n.t(key, :default => :"errors.messages.invalid") unless CNPJ.new(value).valid?
|
10
11
|
end
|
11
12
|
end
|
data/spec/validates_cnpj_spec.rb
CHANGED
@@ -4,7 +4,6 @@ describe CnpjValidator do
|
|
4
4
|
context "when cnpj is invalid" do
|
5
5
|
before :each do
|
6
6
|
@company = Company.new(:cnpj => "12345")
|
7
|
-
I18n.stub(:t).with("activerecord.errors.models.company.attributes.cnpj.invalid").and_return("is invalid")
|
8
7
|
end
|
9
8
|
|
10
9
|
it "should set object as invalid" do
|