Class: WhyValidationsSuckIn96::ValidatesExclusion
- Inherits:
-
WhyValidationsSuckIn96::Validation
- Object
- WhyValidationsSuckIn96::Validation
- WhyValidationsSuckIn96::ValidatesExclusion
- Includes:
- WhyValidationsSuckIn96::AttributeBasedValidation, WhyValidationsSuckIn96::SkippableValidation
- Defined in:
- lib/whyvalidationssuckin96/macros/validates_exclusion.rb
Overview
Checks the validity of an attribute against a collection of excluded values.
Constant Summary
- DefaultOptions =
{:message => "is in the excluded collection"}
Constants inherited from WhyValidationsSuckIn96::Validation
Instance Method Summary
- - (ValidatesExclusion) initialize(validatable, options = {}) constructor A new instance of ValidatesExclusion.
- - (Object) validate
Methods included from WhyValidationsSuckIn96::AttributeBasedValidation
Methods inherited from WhyValidationsSuckIn96::Validation
#failed?, #has_run?, #message, new_subclass, #passed?, #validates?
Constructor Details
- (ValidatesExclusion) initialize(validatable, options = {})
A new instance of ValidatesExclusion
21 22 23 24 |
# File 'lib/whyvalidationssuckin96/macros/validates_exclusion.rb', line 21 def initialize(validatable, = {}) super raise(ArgumentError, "Collection to check for exclusion against should be specified with :in") unless [:in] end |
Instance Method Details
- (Object) validate
26 27 28 29 30 31 32 33 |
# File 'lib/whyvalidationssuckin96/macros/validates_exclusion.rb', line 26 def validate super if [:in].include?(attribute_value) fail else pass end end |