Class: WeakParameters::ObjectValidator

Inherits:
HashValidator show all
Defined in:
lib/weak_parameters/object_validator.rb

Instance Attribute Summary collapse

Attributes inherited from BaseValidator

#block, #controller, #options

Instance Method Summary collapse

Methods inherited from BaseValidator

#key, #required?, #type

Constructor Details

#initialize(controller, key, validators, options = {}) ⇒ ObjectValidator

Returns a new instance of ObjectValidator.



4
5
6
7
# File 'lib/weak_parameters/object_validator.rb', line 4

def initialize(controller, key, validators, options = {})
  super controller, key, options
  @validators = validators
end

Instance Attribute Details

#validatorsObject (readonly)

Returns the value of attribute validators.



3
4
5
# File 'lib/weak_parameters/object_validator.rb', line 3

def validators
  @validators
end

Instance Method Details

#validate(*args) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/weak_parameters/object_validator.rb', line 9

def validate(*args)
  super

  if valid? && exist?
    validators.each do |validator|
      validator.validate(*path)
    end
  end
end