Module: ActiveRecord::Validations::Helpers
- Defined in:
- lib/activerecord/validations/helpers.rb
Overview
ActiveRecord helpers worked with validation reflections
Instance Method Summary collapse
Instance Method Details
#validates?(field, type = nil) ⇒ Boolean
9 10 11 12 13 14 15 |
# File 'lib/activerecord/validations/helpers.rb', line 9 def validates?(field, type = nil) if type.nil? validators_on(field).any? else (field, type) end end |
#validation_options(field, type) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/activerecord/validations/helpers.rb', line 17 def (field, type) validation = validators_on(field).find { |v| v.kind == type } if validation.present? validation..present? ? validation. : true else false end end |