Module: Validatable

### Home Classes Methods

### In Files

- lib/child_validation.rb
- lib/errors.rb
- lib/included_validation.rb
- lib/macros.rb
- lib/requireable.rb
- lib/understandable.rb
- lib/validatable_class_methods.rb
- lib/validatable_instance_methods.rb
- lib/validations/validates_acceptance_of.rb
- lib/validations/validates_confirmation_of.rb
- lib/validations/validates_each.rb
- lib/validations/validates_format_of.rb
- lib/validations/validates_length_of.rb
- lib/validations/validates_numericality_of.rb
- lib/validations/validates_presence_of.rb
- lib/validations/validates_true_for.rb
- lib/validations/validation_base.rb

### Namespace

- MODULE Validatable::Macros
- CLASS Validatable::Errors

### Methods

- #errors
- #valid?
- #validate_only

### Files

- README

### Class/Module Index

Quicksearch

- Validatable
- Validatable::Errors
- Validatable::Macros

No matching classes.

# Validatable

### Public Instance Methods

errors click to toggle source

Returns the Errors object that holds all information about attribute error messages.

    # File lib/validatable_instance_methods.rb, line 17
    def errors
      @errors ||= Validatable::Errors.new
    end

valid? click to toggle source

Returns true if no errors were added otherwise false. Only executes validations that have no :groups option specified

    # File lib/validatable_instance_methods.rb, line 10
    def valid?
      valid_for_group?(nil)
    end

validate_only(key) click to toggle source

Only executes a specified validation. The argument should follow a pattern based on the key of the validation.

    Examples:
      * validates_presence_of :name can be run with obj.validate_only("presence_of/name")
      * validates_presence_of :birthday, :key => "a key" can be run with obj.validate_only("presence_of/a key")

    # File lib/validatable_instance_methods.rb, line 49
    def validate_only(key)
      validation_name, attribute_name = key.split("/")
      validation_name = validation_name.split("_").collect{|word| word.capitalize}.join
      validation_key = "#{self.class.name}/Validatable::Validates#{validation_name}/#{attribute_name}"
      validation = self.class.all_validations.find { |validation| validation.key == validation_key }
      raise ArgumentError.new("validation with key #{validation_key} could not be found") if validation.nil?
      errors.clear
      run_validation(validation)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.