| 101 | |
| 102 | |
| 103 | def _validate_object(value: dict[str, Any], schema: Mapping[str, Any], *, path: str, issues: list[ValidationIssue]) -> None: |
| 104 | required = _as_set(schema.get("required")) |
| 105 | properties = schema.get("properties") or {} |
| 106 | additional = schema.get("additionalProperties", True) |
| 107 | |
| 108 | for req in required: |
| 109 | if req not in value: |
| 110 | issues.append(ValidationIssue(path, f"missing required field {req!r}")) |
| 111 | |
| 112 | for key, val in value.items(): |
| 113 | prop_schema = properties.get(key) if isinstance(properties, dict) else None |
| 114 | if prop_schema is None: |
| 115 | if additional is False: |
| 116 | issues.append(ValidationIssue(f"{path}.{key}", "unexpected field")) |
| 117 | continue |
| 118 | if isinstance(prop_schema, dict): |
| 119 | _validate(val, prop_schema, path=f"{path}.{key}", issues=issues) |
| 120 | |
| 121 | |
| 122 | def _is_valid(value: Any, schema: Mapping[str, Any]) -> bool: |