Class: OpenAPIParser::SchemaValidator
- Inherits:
-
Object
- Object
- OpenAPIParser::SchemaValidator
- Includes:
- Validatable
- Defined in:
- lib/openapi_parser/schema_validator/all_of_validator.rb,
lib/openapi_parser/schema_validator.rb,
lib/openapi_parser/schema_validator/base.rb,
lib/openapi_parser/schema_validator/options.rb,
lib/openapi_parser/schema_validator/enumable.rb,
lib/openapi_parser/schema_validator/nil_validator.rb,
lib/openapi_parser/schema_validator/array_validator.rb,
lib/openapi_parser/schema_validator/float_validator.rb,
lib/openapi_parser/schema_validator/minimum_maximum.rb,
lib/openapi_parser/schema_validator/any_of_validator.rb,
lib/openapi_parser/schema_validator/object_validator.rb,
lib/openapi_parser/schema_validator/one_of_validator.rb,
lib/openapi_parser/schema_validator/string_validator.rb,
lib/openapi_parser/schema_validator/boolean_validator.rb,
lib/openapi_parser/schema_validator/integer_validator.rb,
lib/openapi_parser/schema_validator/unspecified_type_validator.rb
Overview
validate AllOf schema
Defined Under Namespace
Modules: Enumable, MinimumMaximum, Validatable Classes: AllOfValidator, AnyOfValidator, ArrayValidator, Base, BooleanValidator, FloatValidator, IntegerValidator, NilValidator, ObjectValidator, OneOfValidator, Options, ResponseValidateOptions, StringValidator, UnspecifiedTypeValidator
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.
52 53 54 55 56 57 |
# File 'lib/openapi_parser/schema_validator.rb', line 52 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
44 45 46 |
# File 'lib/openapi_parser/schema_validator.rb', line 44 def validate(value, schema, ) new(value, schema, ).validate_data end |
Instance Method Details
#validate_data ⇒ Object
execute validate data
61 62 63 64 65 66 |
# File 'lib/openapi_parser/schema_validator.rb', line 61 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
90 91 92 |
# File 'lib/openapi_parser/schema_validator.rb', line 90 def validate_integer(value, schema) integer_validator.coerce_and_validate(value, schema) end |
#validate_schema(value, schema, **keyword_args) ⇒ Object
validate value eby schema
71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/openapi_parser/schema_validator.rb', line 71 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 |