validate
Helper functions to perform validation of JSON-compatible metadata files.
JSONValidationErrors
module-attribute
¶
JSONValidationErrors = Dict[str, List[str]]
JSON validation errors mapping from JSON Pointers to of error message lists.
plugin_from_uri ¶
plugin_from_uri(custom_uri: str) -> ValidationHandler
Parse a validation plugin pseudo-URI, return the plugin class and args string.
Source code in src/dirschema/json/validate.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
|
validate_custom ¶
validate_custom(
dat, plugin_str: str
) -> JSONValidationErrors
Perform validation based on a validation handler string.
Source code in src/dirschema/json/validate.py
35 36 37 38 39 40 41 |
|
validate_jsonschema ¶
validate_jsonschema(
dat, schema: Union[bool, Dict]
) -> JSONValidationErrors
Perform validation of a dict based on a JSON Schema.
Source code in src/dirschema/json/validate.py
44 45 46 47 48 49 50 51 52 53 |
|
resolve_validator ¶
resolve_validator(
schema_or_ref: Union[bool, str, Dict],
*,
local_basedir: Optional[Path] = None,
relative_prefix: str = ""
) -> Union[bool, Dict, ValidationHandler]
Resolve passed object into a schema or validator.
If passed object is already a schema, will return it.
If passed object is a string, will load the referenced schema
or instantiate the custom validator (a string starting with v#
).
Source code in src/dirschema/json/validate.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
|
validate_metadata ¶
validate_metadata(
dat,
schema: Union[bool, str, Dict, ValidationHandler],
*,
local_basedir: Optional[Path] = None,
relative_prefix: str = ""
) -> JSONValidationErrors
Validate object (dict or byte stream) using JSON Schema or custom validator.
The validator must be either a JSON Schema dict, or a string pointing to a JSON Schema, or a custom validator handler string.
Returns a dict mapping from JSON Pointers to a list of errors in that location. If the dict is empty, no validation errors were detected.
Source code in src/dirschema/json/validate.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
|