Module: Validatable
- Defined in:
- lib/errors.rb,
lib/macros.rb,
lib/requireable.rb,
lib/understandable.rb,
lib/child_validation.rb,
lib/validatable_assertions.rb,
lib/validatable_class_methods.rb,
lib/validations/validation_base.rb,
lib/validatable_instance_methods.rb,
lib/validations/validates_true_for.rb,
lib/validations/validates_format_of.rb,
lib/validations/validates_length_of.rb,
lib/validations/validates_presence_of.rb,
lib/validations/validates_acceptance_of.rb,
lib/validations/validates_confirmation_of.rb,
lib/validations/validates_numericality_of.rb
Defined Under Namespace
Modules: Assertions, ClassMethods, Macros, Requireable, Understandable Classes: ChildValidation, Errors, ValidatesAcceptanceOf, ValidatesConfirmationOf, ValidatesFormatOf, ValidatesLengthOf, ValidatesNumericalityOf, ValidatesPresenceOf, ValidatesTrueFor, ValidationBase
Class Method Summary collapse
-
.included(klass) ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#errors ⇒ Object
call-seq: errors.
-
#increment_times_validated_for(validation) ⇒ Object
:nodoc:.
-
#times_validated(key) ⇒ Object
:nodoc:.
-
#valid? ⇒ Boolean
call-seq: valid?.
-
#valid_for_group?(group) ⇒ Boolean
:nodoc:.
Class Method Details
.included(klass) ⇒ Object
:nodoc:
2 3 4 5 |
# File 'lib/validatable_instance_methods.rb', line 2 def self.included(klass) #:nodoc: klass.extend Validatable::ClassMethods klass.extend Validatable::Macros end |
Instance Method Details
#errors ⇒ Object
call-seq: errors
Returns the Errors object that holds all information about attribute error messages.
17 18 19 |
# File 'lib/validatable_instance_methods.rb', line 17 def errors @errors ||= Validatable::Errors.new end |
#increment_times_validated_for(validation) ⇒ Object
:nodoc:
32 33 34 35 36 37 38 39 40 |
# File 'lib/validatable_instance_methods.rb', line 32 def increment_times_validated_for(validation) #:nodoc: if validation.key != nil if times_validated_hash[validation.key].nil? times_validated_hash[validation.key] = 1 else times_validated_hash[validation.key] += 1 end end end |
#times_validated(key) ⇒ Object
:nodoc:
28 29 30 |
# File 'lib/validatable_instance_methods.rb', line 28 def times_validated(key) #:nodoc: times_validated_hash[key] || 0 end |
#valid? ⇒ Boolean
call-seq: valid?
Returns true if no errors were added otherwise false. Only executes validations that have no :groups option specified
10 11 12 |
# File 'lib/validatable_instance_methods.rb', line 10 def valid? valid_for_group?(nil) end |
#valid_for_group?(group) ⇒ Boolean
:nodoc:
21 22 23 24 25 26 |
# File 'lib/validatable_instance_methods.rb', line 21 def valid_for_group?(group) #:nodoc: errors.clear self.class.validate_children(self, group) self.validate(group) errors.empty? end |