Sha256: c3cbb47aa54d5708a22fe39121ff4aab1b20b0baf17e73ef9c69229afb347714

Contents?: true

Size: 571 Bytes

Versions: 2

Compression:

Stored size: 571 Bytes

Contents

require "validates_cnpj/cnpj"

#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
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
validates_cnpj-1.1.3 lib/validates_cnpj.rb
validates_cnpj-1.1.2 lib/validates_cnpj.rb