-
Notifications
You must be signed in to change notification settings - Fork 153
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
Simplify implementations of UUID and URL validators. #101
Labels
maintenance
PR: Alters existing source code
Comments
Thanks for suggestions!
|
yozachar
added a commit
to yozachar/pyvalidators
that referenced
this issue
Mar 7, 2023
- reformats `mac_address`, `slug` and `uuid` modules - removes less relevant `truthy` module - uses type hints, adds doc refs - updates related tests **Related items** *Issues* - Closes python-validators#101 - Closes python-validators#109
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A few thoughts that I think would help improve flexibility of your code:
For the UUID validator
Instead of using a pattern matcher which doesn’t accept valid strings without hyphens (e.g.
"1219ffcf45c78964b04a3290cf84183a"
), why not just use Python’s ownuuid
module?For the URL validator
Again an impressive funk of patterns 😉Why not use the rfc3987 module like so:
Note that this module also gives you a whole heap of regexes which you could use here instead of duplicating code.
And…
To simplify the above code, you’d also move the exception handling into the decorator:
The text was updated successfully, but these errors were encountered: