Class: ApipieDSL::Validator::NestedValidator
Instance Attribute Summary
#param_description
Class Method Summary
collapse
Instance Method Summary
collapse
#==, #docs, find, inherited, #inspect, #inspected_fields, #merge_with, #to_s, #valid?
Constructor Details
#initialize(param_description, argument, param_group) ⇒ NestedValidator
Returns a new instance of NestedValidator.
465
466
467
468
469
|
# File 'lib/apipie_dsl/validator.rb', line 465
def initialize(param_description, argument, param_group)
super(param_description)
@validator = HashValidator.new(param_description, argument, param_group)
@type = argument
end
|
Class Method Details
.build(param_description, argument, options, block) ⇒ Object
471
472
473
474
475
|
# File 'lib/apipie_dsl/validator.rb', line 471
def self.build(param_description, argument, options, block)
return if argument != Array || !block.is_a?(Proc) || block.arity.positive?
new(param_description, block, options[:param_group])
end
|
Instance Method Details
#description ⇒ Object
491
492
493
|
# File 'lib/apipie_dsl/validator.rb', line 491
def description
'Must be an Array of nested elements'
end
|
#expected_type ⇒ Object
487
488
489
|
# File 'lib/apipie_dsl/validator.rb', line 487
def expected_type
'array'
end
|
#sub_params ⇒ Object
495
496
497
|
# File 'lib/apipie_dsl/validator.rb', line 495
def sub_params
@validator.sub_params
end
|
#validate(value) ⇒ Object
477
478
479
480
481
482
483
484
485
|
# File 'lib/apipie_dsl/validator.rb', line 477
def validate(value)
value ||= []
return false if value.class != Array
value.each do |child|
return false unless @validator.validate(child)
end
true
end
|