handler
Interface for custom validation handlers.
ValidationHandler ¶
Bases: ABC
Interface for custom validators that can be registered via entrypoints.
Only one of validate or validate_json may be implemented.
These can be used instead of JSON Schemas inside a dirschema like this:
validMeta: "v#ENTRYPOINT://any args for validator, e.g. schema name"
Source code in src/dirschema/json/handler.py
7 8 9 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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
|
__init__ ¶
__init__(args: str)
Store passed arguments in instance.
Source code in src/dirschema/json/handler.py
17 18 19 |
|
validate ¶
validate(data) -> Dict[str, List[str]]
Run validation on passed metadata object.
Source code in src/dirschema/json/handler.py
26 27 28 29 30 31 |
|
validate_raw
classmethod
¶
validate_raw(
data: IO[bytes], args: str
) -> Dict[str, List[str]]
Perform custom validation on passed raw binary stream.
This can be used to implement validators for files that are not JSON or not parsable as JSON by the adapter used in combination with the handler.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
IO[bytes]
|
Binary data stream |
required |
args |
str
|
String following the entry-point prefix, i.e.
when used as |
required |
Returns:
Type | Description |
---|---|
Dict[str, List[str]]
|
The output is a dict mapping from paths (JSON Pointers) inside the |
Dict[str, List[str]]
|
object to respective collected error messages. |
Dict[str, List[str]]
|
If there are no errors, an empty dict is returned. |
Source code in src/dirschema/json/handler.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
|
validate_json
classmethod
¶
validate_json(data: Any, args: str) -> Dict[str, List[str]]
Perform custom validation on passed JSON dict.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
Any
|
Valid JSON dict loaded by a dirschema adapter. |
required |
args |
str
|
String following the entry-point prefix, i.e.
when used as |
required |
Returns:
Type | Description |
---|---|
Dict[str, List[str]]
|
The output is a dict mapping from paths (JSON Pointers) inside the |
Dict[str, List[str]]
|
object to respective collected error messages. |
Dict[str, List[str]]
|
If there are no errors, an empty dict is returned. |
Source code in src/dirschema/json/handler.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
|