Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DictValidator: Allow non-string keys / customizable key validation #114

Open
binaryDiv opened this issue Apr 11, 2024 · 0 comments
Open
Assignees
Labels
enhancement Improvements to existing features or smaller new features question Further information is requested
Milestone

Comments

@binaryDiv
Copy link
Contributor

Currently, the DictValidator only allows strings as dictionary keys.

Originally the reason for this was purely "we mostly want to use this with JSON and JSON doesn't support non-string keys anyway", but there are cases where non-string keys (e.g. integers) can be useful.

There are some open questions about this, though.

  • It could(?) still make sense to have optional data type validation for keys, or even more specific/custom validation by specifying an arbitrary Validator as key_validator.
  • If we allow key validators, it could be an option to have "light-weight" validation that only checks the type (so instead of specifying a Validator, just specify the type and the DictValidator will only do a isinstance check.
  • Do we allow field validators for arbitrary key types too? (I don't see why not, but it could have some unexpected effects on testing, for example.)
  • What should the default be? Allow any type, or keep the current behaviour (strings only) as the default?
@binaryDiv binaryDiv added enhancement Improvements to existing features or smaller new features question Further information is requested labels Apr 11, 2024
@binaryDiv binaryDiv self-assigned this Apr 11, 2024
@binaryDiv binaryDiv added this to the 1.0.0 Release milestone Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvements to existing features or smaller new features question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant