Class: WhyValidationsSuckIn96::ValidatesLength
- Inherits:
-
WhyValidationsSuckIn96::Validation
- Object
- WhyValidationsSuckIn96::Validation
- WhyValidationsSuckIn96::ValidatesLength
- Includes:
- WhyValidationsSuckIn96::AttributeBasedValidation, WhyValidationsSuckIn96::SkippableValidation
- Defined in:
- lib/whyvalidationssuckin96/macros/validates_length.rb
Overview
Checks the validity of an attribute against a given set of sizes.
Constant Summary
- DefaultOptions =
{:message => "does not meet the given length restrictions"}
- ValidOptions =
[:is, :in, :minimum, :maximum]
- OptionIncompatibility =
{ :is => [:minimum, :maximum, :in], :in => [:minimum, :maximum, :is] }
Constants inherited from WhyValidationsSuckIn96::Validation
Instance Method Summary
- - (ValidatesLength) initialize(validatable, options = {}) constructor A new instance of ValidatesLength.
- - (Object) validate
Methods included from WhyValidationsSuckIn96::AttributeBasedValidation
Methods inherited from WhyValidationsSuckIn96::Validation
#failed?, #has_run?, #message, new_subclass, #passed?, #validates?
Constructor Details
- (ValidatesLength) initialize(validatable, options = {})
A new instance of ValidatesLength
49 50 51 52 |
# File 'lib/whyvalidationssuckin96/macros/validates_length.rb', line 49 def initialize(validatable, = {}) super () end |
Instance Method Details
- (Object) validate
54 55 56 57 58 59 60 61 |
# File 'lib/whyvalidationssuckin96/macros/validates_length.rb', line 54 def validate super all_valid = ValidOptions.collect do |opt_name| next(true) if [opt_name].nil? send(:"validate_#{opt_name}") end.all? all_valid ? pass : fail end |