Sha256: 61440ed05bde2bfe549bc8f8a7c8758129ff2b6061e1ab1a8b60bab1d28d26bf
Contents?: true
Size: 737 Bytes
Versions: 5
Compression:
Stored size: 737 Bytes
Contents
require "shoulda-matchers" module Shoulda module Matchers module ActiveModel def require_a_valid_cpf(attr = :cpf) RequireAValidCpfMatcher.new(attr) end class RequireAValidCpfMatcher < ValidationMatcher def initialize(attribute) @attribute = attribute end def description "require a valid CPF number" end def matches?(subject) super(subject) disallows_invalid_value and allows_valid_value end private def disallows_invalid_value disallows_value_of("123456") end def allows_valid_value allows_value_of("897.546.112-20") end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems