拡張バリデーターを作成します

jsonschema.validators.create(meta_schema, validators=(), version=None, default_types=None)[ソース]

バリデータ(クラス)を作成します。

パラメタ:
  • meta_schema (dict) – 新しいバリデーター クラスのメタスキーマ
  • validators (dict) – バリデーターの名前から、指定した名前を検証する関数へのマッピング各関数は、4 個の引数を取る必要があります: 検証インスタンス、検証対象のインスタンスで、現在「validator」プロパティーの値、インスタンス、およびスキーマです。
  • version (str) – この検証コントロールが検証するバージョンの識別子です。提供、返さバリデータ クラスがその ‘__name__ ‘ に設定、バージョンが含まれていてもが: func: ‘を検証’ 特定のバージョンを自動的に呼び出されます。
  • default_types (dict) – a default mapping to use for instances of the validator when mapping between JSON types to Python types. The default for this argument is probably fine. Instances of the returned validator can still have their types customized on a per-instance basis.
戻り値:

新しい jsonschema.IValidator クラス

jsonschema.validators.extend(validator, validators, version=None)[ソース]

既存のバリデータを拡張して新しいバリデータを作成します

パラメタ:
  • validator (jsonschema.IValidator) – 既存のバリデータクラス
  • validators (dict) –

    新しく追加されたバリデータのセット

    ノート

    既存のものと同じ名前を持つ任意のバリデータは(静かに) 完全に古いバリデータに置き換えられます。

    もし古いバリデータを拡張したいなら、使っている OldValidator.VALIDATORS["the validator"]

  • version (str) – バリデーターの新しいバージョン
戻り値:

新しい jsonschema.IValidator クラス

ノート

メタスキーマ

新しいバリデータは単に古いバリデータのメタスキーマを維持するでしょう。

メタスキーマを新しいバリデータで変更/拡張したい時は、 返却されるクラス上で``META_SCHEMA`` を直接変更します。

The meta schema on the new validator will not be a copy, so you’ll probably want to copy it before modifying it to not affect the old validator.

jsonschema.validators.validator_for(schema, default=<unset>)[ソース]

バリデーションするスキーマに適切なバリデータを検索します。

Uses the $schema property that should be present in the given schema to look up the appropriate validator.

パラメタ:
  • schema – このスキーマはぱっと見
  • default – 適切なバリデータを特定できない場合に返すデフォルトです。意図しないものの場合、デフォルトでは単に Draft4Validator を返します。
jsonschema.validators.validates(version)[ソース]

バージョンを特定する為のデコレーションされたバリデータを保存します。

バリデータを保存しました。またそれらのメタスキーマは $schema 属性の URIを解析するときに考慮されます。

パラメタ:version (str) – バージョン名として使用する為の識別子
戻り値:バージョンのバリデータをデコレーションするためのクラスデコレータ

バリデーションエラーを作る

Any validating function that validates against a subschema should call ValidatorMixin.descend(), rather than ValidatorMixin.iter_errors(). If it recurses into the instance, or schema, it should pass one or both of the path or schema_path arguments to ValidatorMixin.descend() in order to properly maintain where in the instance or schema respsectively the error occurred.