Class: Openapi3Parser::NodeFactory::Array::ValidNodeBuilder
- Inherits:
-
Object
- Object
- Openapi3Parser::NodeFactory::Array::ValidNodeBuilder
- Defined in:
- lib/openapi3_parser/node_factory/array.rb
Class Method Summary collapse
Instance Method Summary collapse
- #data(parent_context) ⇒ Object
- #errors ⇒ Object
-
#initialize(factory) ⇒ ValidNodeBuilder
constructor
A new instance of ValidNodeBuilder.
Constructor Details
#initialize(factory) ⇒ ValidNodeBuilder
Returns a new instance of ValidNodeBuilder.
100 101 102 103 |
# File 'lib/openapi3_parser/node_factory/array.rb', line 100 def initialize(factory) @factory = factory @validatable = Validation::Validatable.new(factory) end |
Class Method Details
.data(factory, parent_context) ⇒ Object
96 97 98 |
# File 'lib/openapi3_parser/node_factory/array.rb', line 96 def self.data(factory, parent_context) new(factory).data(parent_context) end |
.errors(factory) ⇒ Object
92 93 94 |
# File 'lib/openapi3_parser/node_factory/array.rb', line 92 def self.errors(factory) new(factory).errors end |
Instance Method Details
#data(parent_context) ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/openapi3_parser/node_factory/array.rb', line 113 def data(parent_context) return default_value if factory.nil_input? TypeChecker.raise_on_invalid_type(factory.context, type: ::Array) check_values(raise_on_invalid: true) validate(raise_on_invalid: true) factory.data.each_with_index.map do |value, i| if value.respond_to?(:node) Node::Placeholder.new(value, i, parent_context) else value end end end |
#errors ⇒ Object
105 106 107 108 109 110 111 |
# File 'lib/openapi3_parser/node_factory/array.rb', line 105 def errors return validatable.collection if factory.nil_input? TypeChecker.validate_type(validatable, type: ::Array) return validatable.collection if validatable.errors.any? collate_errors validatable.collection end |