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

Add choices parameter to all fields #57

Closed
wants to merge 13 commits into from

Conversation

mlaradji
Copy link

@mlaradji mlaradji commented Feb 1, 2020

This PR resolves #35. It uses the typesystem.Choice class to add choice validation to the base ModelField class. I have verified that it is working with at least the Integer and String fields.

@tomchristie
Copy link
Member

Looks nice! I've not really figured out how this interacts in the integer case, since it's typed as str choices.

Also, looks like the test case needs some tweaking?... https://travis-ci.org/encode/orm/jobs/654198625?utm_medium=notification&utm_source=github_status

@mlaradji
Copy link
Author

@tomchristie My mypy does complain that it expects a str in choices. However, the tests show that boolean and integer choices are handled okay. Maybe the choices class types can be relaxed a bit, or maybe something else is happening here (the class maybe converts everything to string before comparing, which can have undesirable results, or it might in some cases require to use string only functions, breaking the functionality.)

@aminalaee aminalaee closed this Nov 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support choices
3 participants