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

Accept uuid.UUID objects in UUID validator #769

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

TurnrDev
Copy link

@TurnrDev TurnrDev commented Feb 9, 2023

Fixes #549 and pallets-eco/flask-admin#1444

Better implementation of #609

@TurnrDev TurnrDev marked this pull request as ready for review February 9, 2023 16:28
@TurnrDev TurnrDev marked this pull request as draft February 9, 2023 16:37
@TurnrDev TurnrDev marked this pull request as ready for review February 9, 2023 16:42
@TurnrDev
Copy link
Author

TurnrDev commented Feb 9, 2023

Test Result:

================================================= test session starts =================================================
platform win32 -- Python 3.10.2, pytest-7.2.1, pluggy-1.0.0 -- C:\Users\JayTurner\.virtualenvs\wtforms-V-P53RkO\Scripts\python.exe
cachedir: .pytest_cache
rootdir: C:\Users\JayTurner\Personal\wtforms, configfile: setup.cfg
collected 7 items

tests/validators/test_uuid.py::test_valid_uuid_passes[2bc1c94f-0deb-43e9-92a1-4775189ec9f8] PASSED               [ 14%]
tests/validators/test_uuid.py::test_valid_uuid_passes[2bc1c94f0deb43e992a14775189ec9f8] PASSED                   [ 28%]
tests/validators/test_uuid.py::test_valid_uuid_passes[uuid_val2] PASSED                                          [ 42%]
tests/validators/test_uuid.py::test_bad_uuid_raises[2bc1c94f-deb-43e9-92a1-4775189ec9f8] PASSED                  [ 57%]
tests/validators/test_uuid.py::test_bad_uuid_raises[2bc1c94f-0deb-43e9-92a1-4775189ec9f] PASSED                  [ 71%]
tests/validators/test_uuid.py::test_bad_uuid_raises[gbc1c94f-0deb-43e9-92a1-4775189ec9f8] PASSED                 [ 85%]
tests/validators/test_uuid.py::test_bad_uuid_raises[2bc1c94f 0deb-43e9-92a1-4775189ec9f8] PASSED                 [100%]

================================================== 7 passed in 0.02s ==================================================

@TurnrDev
Copy link
Author

I have reformted the imports on re the tox style checks and added a changelog entry

@azmeuk azmeuk added the enhancement New feature, or existing feature improvement label Jul 22, 2023
@azmeuk
Copy link
Member

azmeuk commented Oct 9, 2023

Hi @TurnrDev
I was thinking about this PR and I was wondering: if the validator gets UUID objects in the end, that means that it has been initialized (with model data for instance), and it has been validated without formdata (else the formdata would have been validated, and formdata can only be strings). Out of curiosity, why do you validate your model data?

@TurnrDev
Copy link
Author

TurnrDev commented Oct 9, 2023

Hi @azmeuk

I encoured this issue when using flask-admin with sqlalchemy. I can't say for sure why they're doing what they're doing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature, or existing feature improvement
Development

Successfully merging this pull request may close these issues.

UUID validator fails if field.data is a UUID object instead of str
2 participants