Sha256: cf6715bd2378c983784038fee4ff3818a46ee32f3143b88d8c6d86962f04240f
Contents?: true
Size: 545 Bytes
Versions: 1
Compression:
Stored size: 545 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 ruby_prior_version_three = Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.0.0') if ruby_prior_version_three record.errors.add(attribute, :invalid, options) else record.errors.add(attribute, :invalid, **options) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
validates_cpf-3.1.0 | lib/validates_cpf/cpf_validator.rb |