Sha256: 944156c448fc4088af7e2b0b2604e94ce17bcde8093077d27459d504bb9e425d

Contents?: true

Size: 240 Bytes

Versions: 6

Compression:

Stored size: 240 Bytes

Contents

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

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

Version data entries

6 entries across 6 versions & 1 rubygems

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