Class: OpenAPIParser::SchemaValidator
- Inherits:
-
Object
- Object
- OpenAPIParser::SchemaValidator
- Includes:
- Validatable
- Defined in:
- lib/openapi_parser/schema_validators/all_of_validator.rb,
lib/openapi_parser/schema_validator.rb,
lib/openapi_parser/schema_validators/base.rb,
lib/openapi_parser/schema_validators/options.rb,
lib/openapi_parser/schema_validators/enumable.rb,
lib/openapi_parser/schema_validators/nil_validator.rb,
lib/openapi_parser/schema_validators/array_validator.rb,
lib/openapi_parser/schema_validators/float_validator.rb,
lib/openapi_parser/schema_validators/any_of_validator.rb,
lib/openapi_parser/schema_validators/object_validator.rb,
lib/openapi_parser/schema_validators/one_of_validator.rb,
lib/openapi_parser/schema_validators/string_validator.rb,
lib/openapi_parser/schema_validators/boolean_validator.rb,
lib/openapi_parser/schema_validators/integer_validator.rb
Overview
validate AllOf schema
Defined Under Namespace
Modules: Enumable, Validatable Classes: AllOfValidator, AnyOfValidator, ArrayValidator, Base, BooleanValidator, FloatValidator, IntegerValidator, NilValidator, ObjectValidator, OneOfValidator, Options, ResponseValidateOptions, StringValidator
Class Method Summary collapse
-
.validate(value, schema, options) ⇒ Object
validate schema data.
Instance Method Summary collapse
-
#initialize(value, schema, options) ⇒ SchemaValidator
constructor
A new instance of SchemaValidator.
-
#validate_data ⇒ Object
execute validate data.
-
#validate_integer(value, schema) ⇒ Object
validate integer value by schema this method use from float_validator because number allow float and integer.
-
#validate_schema(value, schema, **keyword_args) ⇒ Object
validate value eby schema.
Constructor Details
#initialize(value, schema, options) ⇒ SchemaValidator
Returns a new instance of SchemaValidator.
50 51 52 53 54 55 |
# File 'lib/openapi_parser/schema_validator.rb', line 50 def initialize(value, schema, ) @value = value @schema = schema @coerce_value = .coerce_value @datetime_coerce_class = .datetime_coerce_class end |
Class Method Details
.validate(value, schema, options) ⇒ Object
validate schema data
42 43 44 |
# File 'lib/openapi_parser/schema_validator.rb', line 42 def validate(value, schema, ) new(value, schema, ).validate_data end |
Instance Method Details
#validate_data ⇒ Object
execute validate data
59 60 61 62 63 64 |
# File 'lib/openapi_parser/schema_validator.rb', line 59 def validate_data coerced, err = validate_schema(@value, @schema) raise err if err coerced end |
#validate_integer(value, schema) ⇒ Object
validate integer value by schema this method use from float_validator because number allow float and integer
88 89 90 |
# File 'lib/openapi_parser/schema_validator.rb', line 88 def validate_integer(value, schema) integer_validator.coerce_and_validate(value, schema) end |
#validate_schema(value, schema, **keyword_args) ⇒ Object
validate value eby schema
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/openapi_parser/schema_validator.rb', line 69 def validate_schema(value, schema, **keyword_args) return [value, nil] unless schema if (v = validator(value, schema)) if keyword_args.empty? return v.coerce_and_validate(value, schema) else return v.coerce_and_validate(value, schema, **keyword_args) end end # unknown return error OpenAPIParser::ValidateError.build_error_result(value, schema) end |