aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/edify/library/__init__.py2
-rw-r--r--src/edify/library/mac.py16
-rw-r--r--src/edify/library/ssn.py16
3 files changed, 34 insertions, 0 deletions
diff --git a/src/edify/library/__init__.py b/src/edify/library/__init__.py
index 62d6528..5f091e8 100644
--- a/src/edify/library/__init__.py
+++ b/src/edify/library/__init__.py
@@ -13,3 +13,5 @@ from .uuid import uuid
from .zip import zip
from .guid import guid
from .password import password
+from .ssn import ssn
+from .mac import mac
diff --git a/src/edify/library/mac.py b/src/edify/library/mac.py
new file mode 100644
index 0000000..9a8cf8f
--- /dev/null
+++ b/src/edify/library/mac.py
@@ -0,0 +1,16 @@
+import re
+
+mac_address_validate_pattern = "^(?:[0-9A-Fa-f]{2}[:-]){5}(?:[0-9A-Fa-f]{2})$"
+
+def mac(mac: str) -> bool:
+ """Validate a MAC (IEEE 802) address.
+
+ Args:
+ mac (str): The MAC address to validate.
+
+ Returns:
+ bool: True if the MAC address is valid, False otherwise.
+ """
+ if not isinstance(mac, str):
+ return False
+ return bool(re.match(mac_address_validate_pattern, mac))
diff --git a/src/edify/library/ssn.py b/src/edify/library/ssn.py
new file mode 100644
index 0000000..8f42de6
--- /dev/null
+++ b/src/edify/library/ssn.py
@@ -0,0 +1,16 @@
+import re
+
+ssn_validate_pattern = "^(?!666|000|9\\d{2})\\d{3}-(?!00)\\d{2}-(?!0{4})\\d{4}$"
+
+def ssn(ssn: str) -> bool:
+ """Validate a Social Security Number (SSN).
+
+ Args:
+ ssn (str): The SSN to validate.
+
+ Returns:
+ bool: True if the SSN is valid, False otherwise.
+ """
+ if not isinstance(ssn, str):
+ return False
+ return bool(re.match(ssn_validate_pattern, ssn))