keleshev / schema

Schema validation just got Pythonic
MIT License
2.88k stars 215 forks source link

Incorrect error reporting for key schema #255

Open wwoods opened 3 years ago

wwoods commented 3 years ago
import schema

schema.Schema({schema.And(str, lambda x: '-' in x, error="Helpful error message"): int}).validate({'hey': 8, 'yo-there': 9})

Expected: the user would get the "Helpful error message" pointing at the key name.

Actual: SchemaWrongKeyError: Wrong key 'hey' in {'hey': 8, 'yo-there': 9}

fedemgp commented 1 year ago

Any update about this issue? i came here with the same problem using schema.Regex as a key validator. If you guys want, i can make a PR changing that