required, additionalProperties, propertyNames, dependentRequired and any other validators that reference property *names* need a way to indicate the erroring names in ValidationErrors
还没有人认领这个 Issue。
评估
调研方向
首先检查 ValidationError 现有的 path、schema_path 和 message 字段,然后查看 required、additionalProperties、propertyNames 和 dependentRequired 验证器如何构造错误。完成的标准是相关错误直接暴露有问题的属性名称,并且测试覆盖缺失和无效属性名称的情况,而不解析 error.message。
由索引模型根据 Issue 内容生成。
描述
Trying to figure out if there is a way to retrieve the name of a missing required property from an error (without hacking it out of error.message).
For example:
from jsonschema import Draft4Validator as Validator
schema = {
'type': 'object',
'properties': {
'a': {
'type': 'string'
},
'b': {
'type': 'string',
'pattern': '^hello$'
}
},
'required': ['a', 'b']
}
errors = Validator(schema).iter_errors({'b': 'world'})
for error in errors:
print error.path, error.schema_path, error.message
# deque([]) deque(['required']) 'a' is a required property
# deque(['b']) deque(['properties', 'b', 'pattern']) 'world' does not match '^hello$'
In error.path and error.schema_path there is no mention of 'a'. Is there a way to determine that the property missing was 'a' without using error.message?
- 主要语言
- Python
- 星标
- 5k
- 派生
- 694
- 平均合并
- 1 天 20 小时
- 30 天内合并 PR
- 6
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
python-jsonschema/jsonschema 的其他 Issue
-
Iterator error contexts lose parent links and absolute paths可能重新可做 @DawnofGenX 于 8 天前认领,目前没有进行中的 PR。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
python-jsonschema/jsonschema#1584 · 3 条评论 ·
-
regex format checker crashes with RecursionError on deeply nested patterns可能已有人在做 @DawnofGenX 于 8 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
python-jsonschema/jsonschema#1538 · 1 条评论 ·
-
is_duration raises an uncaught decimal.Overflow on a duration with a large exponent可能重新可做 关联的 PR 已关闭且未合并。 未关闭Needs Test Upstream
难度 2/5 1-3 小时 新手友好度 78/100
python-jsonschema/jsonschema#1511 · 1 条评论 ·
-
regex format checker crashes with ValueError on conflicting inline flags可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 3/5 1-2 天 新手友好度 68/100
python-jsonschema/jsonschema#1558 · 2 条评论 ·
-
难度 4/5 3-5 天 新手友好度 45/100
python-jsonschema/jsonschema#1547 ·
查看 python-jsonschema/jsonschema 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
task
难度 2/5 1-3 小时 新手友好度 78/100
danparshall/claude_researcher#87 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 85/100
datajoint/datajoint-python#1586 ·
维护者通常 1 天内回复
-
1D intercept of length 1 is accepted as `fix_params` in population GLM with more than 1 unit可能已有人在做 @dhvani7014 今天认领。 未关闭bug good first issue
难度 2/5 1-3 小时 新手友好度 72/100
flatironinstitute/nemos#642 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 78/100
uniswap-python/uniswap-python#487 ·