Formats

List of bundled formats

To enable format validation with bundled format checkers:

  1. Create an instance of jsonschema.FormatChecker, or use an existing format checker instance.

  2. Register the desired format checking functions to the format checker using register_funcs_in_checker() or register_func_in_checker() with bundled FormatCheckingFuncInfo instances.

  3. Pass the format checker to jsonschema.validate() or to your jsonschema.protocols.Validator instance 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)