Class: Roart::Validations::Validators

Inherits:
Object
  • Object
show all
Defined in:
lib/roart/validations.rb

Instance Method Summary collapse

Constructor Details

#initializeValidators

Returns a new instance of Validators.



64
65
66
# File 'lib/roart/validations.rb', line 64

def initialize
  @validators = []
end

Instance Method Details

#add(validator) ⇒ Object



68
69
70
# File 'lib/roart/validations.rb', line 68

def add(validator)
  @validators << validator
end

#validate(obj) ⇒ Object



72
73
74
75
# File 'lib/roart/validations.rb', line 72

def validate(obj)
  obj.errors.clear
  @validators.each{|validator| validator.call(obj)}
end