diff options
| author | natsuoto <[email protected]> | 2026-07-11 11:44:52 +0530 |
|---|---|---|
| committer | natsuoto <[email protected]> | 2026-07-11 11:44:52 +0530 |
| commit | 380fb6aa8b820fbc814314b766ed66468b019cb1 (patch) | |
| tree | 38f9daf031a58996defed731deb357d5a9908edd | |
| parent | b86f5c04977b9e606ed2e25b1c02a869e4e4762d (diff) | |
| download | edify-380fb6aa8b820fbc814314b766ed66468b019cb1.tar.xz edify-380fb6aa8b820fbc814314b766ed66468b019cb1.zip | |
feat(library/financial): 4 financial patterns (currency, card, wallet, crypto)
| -rw-r--r-- | edify/library/financial/__init__.py | 6 | ||||
| -rw-r--r-- | edify/library/financial/card.py | 10 | ||||
| -rw-r--r-- | edify/library/financial/crypto.py | 15 | ||||
| -rw-r--r-- | edify/library/financial/currency.py | 15 | ||||
| -rw-r--r-- | edify/library/financial/wallet.py | 19 |
5 files changed, 65 insertions, 0 deletions
diff --git a/edify/library/financial/__init__.py b/edify/library/financial/__init__.py new file mode 100644 index 0000000..9bf261b --- /dev/null +++ b/edify/library/financial/__init__.py @@ -0,0 +1,6 @@ +from edify.library.financial.card import card +from edify.library.financial.crypto import crypto +from edify.library.financial.currency import currency +from edify.library.financial.wallet import wallet + +__all__ = ["card", "crypto", "currency", "wallet"] diff --git a/edify/library/financial/card.py b/edify/library/financial/card.py new file mode 100644 index 0000000..c6829d2 --- /dev/null +++ b/edify/library/financial/card.py @@ -0,0 +1,10 @@ +"""``card`` — credit-card number shape (13–19 digits, optional dash/space separators).""" + +from __future__ import annotations + +from edify.library._support.regex import RegexBackedPattern + +card = RegexBackedPattern(r"^\d{4}[- ]?\d{4}[- ]?\d{4}[- ]?\d{1,7}$") +"""Callable :class:`Pattern` for credit-card number shape: +groups of 4 digits with optional dash/space separators, 13–19 digits total. +""" diff --git a/edify/library/financial/crypto.py b/edify/library/financial/crypto.py new file mode 100644 index 0000000..f2f01a2 --- /dev/null +++ b/edify/library/financial/crypto.py @@ -0,0 +1,15 @@ +"""``crypto`` — cryptocurrency ticker/mint identifier shape.""" + +from __future__ import annotations + +from edify import Pattern + +crypto = ( + Pattern() + .start_of_input() + .between(3, 10).any_of().range("A", "Z").range("0", "9").end() + .end_of_input() +) +"""Callable :class:`Pattern` for a cryptocurrency ticker shape: +3–10 uppercase-alphanumeric characters (``BTC``, ``ETH``, ``USDT``, ``SHIB``, …). +""" diff --git a/edify/library/financial/currency.py b/edify/library/financial/currency.py new file mode 100644 index 0000000..da67aa8 --- /dev/null +++ b/edify/library/financial/currency.py @@ -0,0 +1,15 @@ +"""``currency`` — ISO 4217 currency-code shape (3 uppercase letters).""" + +from __future__ import annotations + +from edify import Pattern + +currency = ( + Pattern() + .start_of_input() + .exactly(3).any_of().range("A", "Z").end() + .end_of_input() +) +"""Callable :class:`Pattern` for the ISO 4217 currency-code shape: +3 uppercase letters (``USD``, ``EUR``, ``JPY``, …). +""" diff --git a/edify/library/financial/wallet.py b/edify/library/financial/wallet.py new file mode 100644 index 0000000..5acf7ec --- /dev/null +++ b/edify/library/financial/wallet.py @@ -0,0 +1,19 @@ +"""``wallet`` — cryptocurrency wallet-address shape (base58 or hex).""" + +from __future__ import annotations + +from edify.library._support.regex import RegexBackedPattern + +wallet = RegexBackedPattern( + r"^(?:" + r"[13][a-km-zA-HJ-NP-Z1-9]{25,34}" + r"|bc1[a-z0-9]{25,89}" + r"|0x[a-fA-F0-9]{40}" + r"|[LM3][a-km-zA-HJ-NP-Z1-9]{26,33}" + r"|D[5-9A-HJ-NP-U][1-9A-HJ-NP-Za-km-z]{32}" + r"|X[1-9A-HJ-NP-Za-km-z]{33}" + r")$" +) +"""Callable :class:`Pattern` for cryptocurrency-wallet address shapes: +Bitcoin (legacy, SegWit, Bech32), Ethereum, Litecoin, Dogecoin, Dash. +""" |
