judgevet._policy_json
Status: draft.
judgevet._policy_json
Decode policy JSON outside the pure domain.
Examples:
from judgevet import Noul
from judgevet._policy_json import parse_policy
policy = parse_policy(
'{"rules":[{"question":"q","pass":{"noul":{"min":0.5}}}]}',
{"q": Noul()},
)
assert len(policy.rules) == 1
See Also
- judgevet.policy_json: Supported JSON facade.
- judgevet.policy: Pure policy types and functions.
parse_policy(text, questions)
Parse and validate policy JSON against typed questions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Raw JSON policy text. |
required |
questions
|
Mapping[str, Question]
|
Mapping of question names to Question instances. |
required |
Returns:
| Type | Description |
|---|---|
ValidatedPolicy
|
A validated immutable policy. |
Raises:
| Type | Description |
|---|---|
PolicyDefinitionError
|
If policy is invalid, with sanitized diagnostics. |