Module: ActiveModel::Validations::HelperMethods

Defined in:
lib/validators/phony_validator.rb

Instance Method Summary collapse

Instance Method Details

#validates_plausible_phone(*attr_names) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/validators/phony_validator.rb', line 18

def validates_plausible_phone(*attr_names)
  # merged attributes are modified somewhere, so we are cloning them for each validator
  merged_attributes = _merge_attributes(attr_names)

  validates_with PresenceValidator, merged_attributes.clone if merged_attributes[:presence]
  validates_with FormatValidator, merged_attributes.clone if (merged_attributes[:with] or merged_attributes[:without])
  validates_with PhonyPlausibleValidator, merged_attributes.clone
end