Class: Shoulda::Matchers::ActiveModel::RequireAValidTelephoneMatcher

Inherits:
ValidationMatcher
  • Object
show all
Defined in:
lib/validates_telephone/shoulda-matchers/require_a_valid_telephone_matcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(attribute) ⇒ RequireAValidTelephoneMatcher

Returns a new instance of RequireAValidTelephoneMatcher.



11
12
13
14
# File 'lib/validates_telephone/shoulda-matchers/require_a_valid_telephone_matcher.rb', line 11

def initialize(attribute)
  @attribute = attribute
  @options = {}
end

Instance Method Details

#descriptionObject



21
22
23
# File 'lib/validates_telephone/shoulda-matchers/require_a_valid_telephone_matcher.rb', line 21

def description
  "require #{@attribute} to be a valid telephone number"
end

#from(locale) ⇒ Object



16
17
18
19
# File 'lib/validates_telephone/shoulda-matchers/require_a_valid_telephone_matcher.rb', line 16

def from(locale)
  @options[:locale] = locale
  self
end

#matches?(subject) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
28
29
# File 'lib/validates_telephone/shoulda-matchers/require_a_valid_telephone_matcher.rb', line 25

def matches?(subject)
  super(subject)

  disallows_invalid_value and allows_valid_value
end