class Openapi3Parser::NodeFactory::ObjectFactory::Validator::CheckInvalidFields
Attributes
validator[R]
Public Class Methods
call(validator)
click to toggle source
# File lib/openapi3_parser/node_factory/object_factory/validator.rb, line 73 def self.call(validator) new(validator).call end
new(validator)
click to toggle source
# File lib/openapi3_parser/node_factory/object_factory/validator.rb, line 77 def initialize(validator) @validator = validator end
Public Instance Methods
call()
click to toggle source
# File lib/openapi3_parser/node_factory/object_factory/validator.rb, line 81 def call factory.data.each do |name, field| # references can reference themselves and become in a loop next if in_recursive_loop?(field) has_factory_errors = handle_factory_checks(name) next if has_factory_errors || !field.respond_to?(:errors) # We don't add errors when we're building a node as they will # be raised when that child node is built validatable.add_errors(field.errors) unless raise_on_invalid end end
Private Instance Methods
check_field(name, field_config)
click to toggle source
# File lib/openapi3_parser/node_factory/object_factory/validator.rb, line 108 def check_field(name, field_config) return if factory.raw_input[name].nil? context = Context.next_field(factory.context, name, factory.raw_input[name]) field_validatable = Validation::Validatable.new(factory, context: context) valid_input_type = field_config.check_input_type( field_validatable, building_node: raise_on_invalid ) if valid_input_type field_config.validate_field(field_validatable, building_node: raise_on_invalid) end validatable.add_errors(field_validatable.errors) field_validatable.errors end
handle_factory_checks(name)
click to toggle source
# File lib/openapi3_parser/node_factory/object_factory/validator.rb, line 98 def handle_factory_checks(name) field_errors = (check_field(name, factory.field_configs[name]) if factory.field_configs[name]) (field_errors || []).any? end
in_recursive_loop?(field)
click to toggle source
# File lib/openapi3_parser/node_factory/object_factory/validator.rb, line 104 def in_recursive_loop?(field) field.respond_to?(:in_recursive_loop?) && field.in_recursive_loop? end