Sha256: baa6ec8ce60b9977182b631febce741d8c92c9700e1e236968f7a0f3d6670a74

Contents?: true

Size: 333 Bytes

Versions: 1

Compression:

Stored size: 333 Bytes

Contents

require "active_model"
require "validates_cpf/version"
require "validates_cpf/cpf"
require "shoulda-matchers/validate_as_cpf_matcher"

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-0.1.1 lib/validates_cpf.rb