Sha256: a2e8d27acc279e20a58cc230ec17f24957fd6fec8c57574c702d4574452fcfb3

Contents?: true

Size: 329 Bytes

Versions: 1

Compression:

Stored size: 329 Bytes

Contents

# frozen_string_literal: true

class CpfValidator < ActiveModel::EachValidator
  def validate_each(record, attribute, value)
    cpf = ValidatesCpf::Cpf.new(value)

    if cpf.valid?
      record.send("#{attribute}=", cpf.number) if options[:mask]
    else
      record.errors.add(attribute, :invalid, options)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
validates_cpf-3.0.0 lib/validates_cpf/cpf_validator.rb