lib/validates_cnpj.rb in validates_cnpj-1.1.3 vs lib/validates_cnpj.rb in validates_cnpj-2.0.0
- old
+ new
@@ -1,12 +1,6 @@
-require "validates_cnpj/cnpj"
+require 'cnpj_validator'
+require 'require_a_valid_cnpj_matcher' if defined?(::Shoulda)
-#Rspec Matchers
-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)
- key = :"activerecord.errors.models.#{record.class.name.downcase}.attributes.#{attribute.to_s}.invalid"
- record.errors[attribute] << I18n.t(key, :default => :"activerecord.errors.messages.invalid") unless CNPJ.new(value).valid?
- end
+module ValidatesCnpj
+ autoload :Cnpj, 'validates_cnpj/cnpj'
end
\ No newline at end of file