Class: Shoulda::Matchers::ActiveModel::RequireAValidGuatemalaIdentityMatcher

Inherits:
ValidationMatcher
  • Object
show all
Defined in:
lib/validates_guatemala_identity/require_a_valid_guatemala_identity_matcher.rb

Instance Method Summary collapse

Instance Method Details

#descriptionObject



13
14
15
# File 'lib/validates_guatemala_identity/require_a_valid_guatemala_identity_matcher.rb', line 13

def description
  'requires a valid Guatemala Identity'
end

#failure_messageObject



17
18
19
# File 'lib/validates_guatemala_identity/require_a_valid_guatemala_identity_matcher.rb', line 17

def failure_message
  'does not require a valid Guatemala Identity'
end

#matches?(subject) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
24
25
26
27
28
29
# File 'lib/validates_guatemala_identity/require_a_valid_guatemala_identity_matcher.rb', line 21

def matches?(subject)
  super(subject)

  allows_value_of('1234567891507') &&
    allows_value_of('2345678990102') &&
    disallows_value_of('1234567881507') && # invalid checksum
    disallows_value_of('1234567892307') && # invalid state code
    disallows_value_of('1234567891618') # invalid city code
end