Sha256: 72b46451d2d441b6951b147950564043ef97c702cbc369407871d236cdf9ff59

Contents?: true

Size: 425 Bytes

Versions: 1

Compression:

Stored size: 425 Bytes

Contents

require "validates_cpf/cpf"

#Rspec Matchers
require "validates_cpf/shoulda-matchers/require_a_valid_cpf_matcher" if defined?(::Shoulda)
require "validates_cpf/remarkable/require_a_valid_cpf_matcher" if defined?(::Remarkable)

class CpfValidator < ActiveModel::EachValidator
  def validate_each(record, attribute, value)
    record.errors[attribute] << I18n.t("errors.messages.invalid") unless CPF.new(value).valid?
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
validates_cpf-1.0.0 lib/validates_cpf.rb