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

Open
wants to merge 13 commits into
base: master
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

@tomchristie tomchristie commented Feb 24, 2020

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 added 3 commits Feb 26, 2020
@mlaradji
Copy link
Author

@mlaradji mlaradji commented Feb 26, 2020

@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.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

2 participants
You can’t perform that action at this time.