Class: OpenAPIParser::SchemaValidator::StringValidator
- Includes:
- Enumable
- Defined in:
- lib/openapi_parser/schema_validator/string_validator.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #coerce_and_validate(value, schema, **_keyword_args) ⇒ Object
-
#initialize(validator, coerce_value, datetime_coerce_class) ⇒ StringValidator
constructor
A new instance of StringValidator.
Methods included from Enumable
Methods inherited from Base
#validate_discriminator_schema
Constructor Details
#initialize(validator, coerce_value, datetime_coerce_class) ⇒ StringValidator
Returns a new instance of StringValidator.
5 6 7 8 |
# File 'lib/openapi_parser/schema_validator/string_validator.rb', line 5 def initialize(validator, coerce_value, datetime_coerce_class) super(validator, coerce_value) @datetime_coerce_class = datetime_coerce_class end |
Instance Method Details
#coerce_and_validate(value, schema, **_keyword_args) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/openapi_parser/schema_validator/string_validator.rb', line 10 def coerce_and_validate(value, schema, **_keyword_args) return OpenAPIParser::ValidateError.build_error_result(value, schema) unless value.kind_of?(String) value, err = check_enum_include(value, schema) return [nil, err] if err value, err = pattern_validate(value, schema) return [nil, err] if err value, err = validate_max_min_length(value, schema) return [nil, err] if err value, err = validate_email_format(value, schema) return [nil, err] if err value, err = validate_uuid_format(value, schema) return [nil, err] if err value, err = validate_date_format(value, schema) return [nil, err] if err value, err = validate_datetime_format(value, schema) return [nil, err] if err [value, nil] end |