You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 19, 2023. It is now read-only.
import dataclasses
from dataclasses_jsonschema import JsonSchemaMixin
from typing import Iterable, List, Set, Tuple, Union
@dataclasses.dataclass(frozen=True)
class Config(JsonSchemaMixin):
tags: Tuple[Union[str, None]]
Config.from_dict({
'tags': []
})
This leads to a raise like so:
ValidationError Traceback (most recent call last)
~site-packages/dataclasses_jsonschema/__init__.py in _validate(cls, data, validate_enums)
488 else:
--> 489 validate_func(data, cls.json_schema(validate_enums=validate_enums))
490 except JsonSchemaValidationError as e:
~site-packages/jsonschema/validators.py in validate(instance, schema, cls, *args, **kwargs)
933 if error is not None:
--> 934 raise error
935
ValidationError: [] is too short
Failed validating 'minItems' in schema['properties']['tags']:
{'items': [{'type': 'string'}],
'maxItems': 1,
'minItems': 1,
'type': 'array'}
On instance['tags']:
[]
The above exception was the direct cause of the following exception:
ValidationError Traceback (most recent call last)
<ipython-input-3-400dc9903cd4> in <module>
8
9 Config.from_dict({
---> 10 'tags': []
11 })
~site-packages/dataclasses_jsonschema/__init__.py in from_dict(cls, data, validate, validate_enums)
506 non_init_values: Dict[str, Any] = {}
507 if validate:
--> 508 cls._validate(data, validate_enums)
509
510 for f in cls._get_fields():
~site-packages/dataclasses_jsonschema/__init__.py in _validate(cls, data, validate_enums)
489 validate_func(data, cls.json_schema(validate_enums=validate_enums))
490 except JsonSchemaValidationError as e:
--> 491 raise ValidationError(str(e)) from e
492
493 @classmethod
ValidationError: [] is too short
Failed validating 'minItems' in schema['properties']['tags']:
{'items': [{'type': 'string'}],
'maxItems': 1,
'minItems': 1,
'type': 'array'}
On instance['tags']:
[]
Using a list tends to pass validation (but then messes with the hashing since the are mutable)
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hey folks,
Say I have something like:
This leads to a raise like so:
Using a list tends to pass validation (but then messes with the hashing since the are mutable)
The text was updated successfully, but these errors were encountered: