Sha256: ce7cfbaeb5da0663001dadf6d1c18b1ee8cb35b942c715fc2220cf2381bcb6e9

Contents?: true

Size: 244 Bytes

Versions: 6

Compression:

Stored size: 244 Bytes

Contents

class CnpjValidator < ActiveModel::EachValidator
  def validate_each(record, attribute, value)
    return if value.blank?

    cnpj = BrDocuments::CnpjCpf::Cnpj.new(value)
    record.errors.add(attribute, :invalid) unless cnpj.valid?
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
br_documents-0.2.5 lib/br_documents/cnpj_validator.rb
br_documents-0.2.4 lib/br_documents/cnpj_validator.rb
br_documents-0.2.3 lib/br_documents/cnpj_validator.rb
br_documents-0.2.2 lib/br_documents/cnpj_validator.rb
br_documents-0.2.1 lib/br_documents/cnpj_validator.rb
br_documents-0.2.0 lib/br_documents/cnpj_validator.rb