Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions validators/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Validate Anything!"""
# -*- coding: utf-8 -*-
# from ._extremes import AbsMax, AbsMin

from .between import between
from .btc_address import btc_address
Expand Down Expand Up @@ -39,9 +38,7 @@
"length",
"mac_address",
"mastercard",
# "AbsMax",
"md5",
# "AbsMax",
"sha1",
"sha224",
"sha256",
Expand Down
5 changes: 2 additions & 3 deletions validators/btc_address.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
# local
from .utils import validator

_segwit_pattern = re.compile(r"^(bc|tc)[0-3][02-9ac-hj-np-z]{14,74}$")


def _decode_base58(addr: str):
"""Decode base58."""
Expand Down Expand Up @@ -54,7 +52,8 @@ def btc_address(value: str, /):
"""
if value and type(value) is str:
return (
_segwit_pattern.match(value)
# segwit pattern
re.compile(r"^(bc|tc)[0-3][02-9ac-hj-np-z]{14,74}$").match(value)
if value[:2] in ("bc", "tb")
else _validate_old_btc_address(value)
)
Expand Down
16 changes: 8 additions & 8 deletions validators/card.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


@validator
def card_number(value: str):
def card_number(value: str, /):
"""Return whether or not given value is a valid generic card number.

This validator is based on [Luhn's algorithm][1].
Expand Down Expand Up @@ -44,7 +44,7 @@ def card_number(value: str):


@validator
def visa(value: str):
def visa(value: str, /):
"""Return whether or not given value is a valid Visa card number.

Examples:
Expand All @@ -70,7 +70,7 @@ def visa(value: str):


@validator
def mastercard(value: str):
def mastercard(value: str, /):
"""Return whether or not given value is a valid Mastercard card number.

Examples:
Expand All @@ -96,7 +96,7 @@ def mastercard(value: str):


@validator
def amex(value: str):
def amex(value: str, /):
"""Return whether or not given value is a valid American Express card number.

Examples:
Expand All @@ -122,7 +122,7 @@ def amex(value: str):


@validator
def unionpay(value: str):
def unionpay(value: str, /):
"""Return whether or not given value is a valid UnionPay card number.

Examples:
Expand All @@ -148,7 +148,7 @@ def unionpay(value: str):


@validator
def diners(value: str):
def diners(value: str, /):
"""Return whether or not given value is a valid Diners Club card number.

Examples:
Expand All @@ -174,7 +174,7 @@ def diners(value: str):


@validator
def jcb(value: str):
def jcb(value: str, /):
"""Return whether or not given value is a valid JCB card number.

Examples:
Expand All @@ -200,7 +200,7 @@ def jcb(value: str):


@validator
def discover(value: str):
def discover(value: str, /):
"""Return whether or not given value is a valid Discover card number.

Examples:
Expand Down
2 changes: 2 additions & 0 deletions validators/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# standard
from typing import Any, Callable, Dict
from inspect import getfullargspec
from functools import wraps
from itertools import chain


Expand Down Expand Up @@ -66,6 +67,7 @@ def validator(func: Callable[..., Any]):
> *New in version 2013.10.21*.
"""

@wraps(func)
def wrapper(*args: Any, **kwargs: Any):
return (
True
Expand Down