Formats¶
To enable format validation with bundled format checkers:
Create an instance of
jsonschema.FormatChecker, or use an existing format checker instance.Register the desired format checking functions to the format checker using
register_funcs_in_checker()orregister_func_in_checker()with bundledFormatCheckingFuncInfoinstances.Pass the format checker to
jsonschema.validate()or to yourjsonschema.protocols.Validatorinstance to enable format validation
Basic example:
from typing import Any
from jsonschema import FormatChecker, validate
from jsonschema_extras.formats import (
register_funcs_in_checker,
is_numbers_range_info,
is_slice_string_info,
)
schema: Any
instance: Any
format_checker = FormatChecker()
register_funcs_in_checker(
format_checker, [is_numbers_range_info, is_slice_string_info],
)
validate(instance, schema, format_checker=format_checker)