diff options
| author | Bobby <[email protected]> | 2022-11-27 12:12:37 -0500 |
|---|---|---|
| committer | Bobby <[email protected]> | 2022-11-27 12:12:37 -0500 |
| commit | 2076d462ed8c38a1202fd5ca5b20f0e07accbbee (patch) | |
| tree | fd1143b1f69964193eed29e9ad84700060b34793 /src | |
| parent | f5cb8a4d14c48f458039d608f6bd38bea13a881c (diff) | |
| download | edify-2076d462ed8c38a1202fd5ca5b20f0e07accbbee.tar.xz edify-2076d462ed8c38a1202fd5ca5b20f0e07accbbee.zip | |
added uuid validator
Diffstat (limited to 'src')
| -rw-r--r-- | src/edify/library/__init__.py | 1 | ||||
| -rw-r--r-- | src/edify/library/uuid.py | 13 |
2 files changed, 14 insertions, 0 deletions
diff --git a/src/edify/library/__init__.py b/src/edify/library/__init__.py index 16c5651..f2827ea 100644 --- a/src/edify/library/__init__.py +++ b/src/edify/library/__init__.py @@ -9,3 +9,4 @@ from .mail import email from .mail import email_rfc_5322 from .phone import phone_number from .url import url +from .uuid import uuid diff --git a/src/edify/library/uuid.py b/src/edify/library/uuid.py new file mode 100644 index 0000000..a6f2f65 --- /dev/null +++ b/src/edify/library/uuid.py @@ -0,0 +1,13 @@ +import re + +pattern = "^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$" + +def uuid(uuid: str) -> bool: + """Checks if a string is a valid UUID. + + Args: + uuid (str): The string to check. + Returns: + bool: True if the string is a valid UUID, False otherwise. + """ + return re.match(pattern, uuid) is not None |
