Class: Validation::Validator

Inherits:
Object
  • Object
show all
Includes:
Rules
Defined in:
lib/validation/validator.rb

Overview

Validator is a simple ruby validation class. You don’t use it directly inside your classes like just about every other ruby validation class out there. I chose to implement it in this way so I didn’t automatically pollute the namespace of the objects I wanted to validate.

This also solves the problem of validating forms very nicely. Frequently you will have a form that represents many different data objects in your system, and you can pre-validate everything before doing any saving.

Instance Method Summary collapse

Methods included from Rules

#errors, #rule, #rules, #valid?

Constructor Details

#initialize(obj) ⇒ Validator

Returns a new instance of Validator.



111
112
113
# File 'lib/validation/validator.rb', line 111

def initialize(obj)
  @obj = obj
end