feat(validation): name a keyed collection as such when a list is given

This commit is contained in:
2026-10-05 18:57:22 +02:00
parent 8f1c1a775a
commit e52696a509
3 changed files with 5 additions and 4 deletions
+2 -1
View File
@@ -78,7 +78,8 @@ class _Validator:
self.errors.append(f"{path}: expected bool or dict, got {_kind(value)}")
return
if not TYPES[kind](value):
self.errors.append(f"{path}: expected {kind}, got {_kind(value)}")
keyed = len(spec.get("options", {})) == 1 and next(iter(spec["options"])).startswith("<")
self.errors.append(f"{path}: expected {'dict keyed by name' if keyed else kind}, got {_kind(value)}")
return
if "choices" in spec and value not in spec["choices"]:
shown = "" if spec.get("no_log") else f", got {value!r}"
+1 -1
View File
@@ -21,7 +21,7 @@ inputs_fixtures:
name: web01
users:
- name: alice
expect: ["fixture.users: expected dict, got list"]
expect: ["fixture.users: expected dict keyed by name, got list"]
- name: comma-string-for-list
value:
+2 -2
View File
@@ -52,7 +52,7 @@ users_fixtures:
- name: ops
password: pw
expect:
fail: "system.users: expected dict, got list"
fail: "system.users: expected dict keyed by name, got list"
- name: list-rejected-precomputed
precomputed: true
@@ -61,7 +61,7 @@ users_fixtures:
- name: ops
password: pw
expect:
fail: "system.users: expected dict, got list"
fail: "system.users: expected dict keyed by name, got list"
- name: scalar-entry-rejected
system: