matrixlib.schema
module¶
Validate JSON data according to a given schema
-
class
matrixlib.schema.
Array
(value_type: Any)¶ -
Indicates an array that contains values of a given type
-
is_valid
(body: Any) bool ¶
-
-
class
matrixlib.schema.
Intersection
(*base_types: list[Any])¶ -
Indicates that a parameter must satisfy all of the given types
-
is_valid
(body: Any) bool ¶
-
-
class
matrixlib.schema.
Object
(value_type: Any)¶ -
Indicates an object that contains values of a given type
-
is_valid
(body: Any) bool ¶
-
-
class
matrixlib.schema.
Optional
(base_type: Any)¶ -
Indicates that a parameter is optional
-
is_valid
(body: Any) bool ¶
-
-
class
matrixlib.schema.
SchemaHelper
(*args, **kwargs)¶ -
Base class for schema helper classes
-
is_valid
(body: Any) bool ¶
-
-
class
matrixlib.schema.
Union
(*base_types: list[Any])¶ -
Indicates that a parameter may be one of multiple types
-
is_valid
(body: Any) bool ¶
-
-
matrixlib.schema.
ensure_valid
(body: Any, schema: Any) None ¶ -
Throw an exception if the JSON data is not valid
-
matrixlib.schema.
is_valid
(body: Any, schema: Any) bool ¶ -
Check if the JSON data is valid according to the given schema
Example:
>>> is_valid({"foo": 1, "bar": True}, {"foo": int, "bar": bool}) True