Sha256: d7335b4faca6a9c9670d86bccaf4630fe366c0fac9f7550621170ce1abc1f7fe

Contents?: true

Size: 540 Bytes

Versions: 2

Compression:

Stored size: 540 Bytes

Contents

require 'shoulda-matchers'
require 'active_support/core_ext/array/wrap'

module Shoulda
  module Matchers
    module ActiveModel
      def require_a_valid_cnpj(attr = :cnpj)
        RequireAValidCnpjMatcher.new(attr)
      end

      class RequireAValidCnpjMatcher < ValidationMatcher
        def description
          'require a valid CNPJ number'
        end

        def matches?(subject)
          @subject = subject
          disallows_value_of('123456') && allows_value_of('51.114.450/0001-46')
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
validates_cnpj-2.0.1 lib/validates_cnpj/require_a_valid_cnpj_matcher.rb
validates_cnpj-2.0.0 lib/require_a_valid_cnpj_matcher.rb