Class: SexyValidations::Validators::Inclusion
- Inherits:
-
Object
- Object
- SexyValidations::Validators::Inclusion
- Defined in:
- lib/sexy_validations/validators/inclusion.rb
Class Method Summary collapse
Class Method Details
.validate(model, attribute, value, options) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/sexy_validations/validators/inclusion.rb', line 5 def self.validate(model, attribute, value, ) return unless value unless .is_a?(Hash) = { :within => , } end data = case [:within] when Proc [:within].call(model) else [:within] end unless data.include?(value) model.errors.add(attribute, [:message] || "ungültige Auswahl") end end |