Skip to content

chore/numerous improvements #9

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

Merged
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
d134150
Comparisons to None and other singleton objects should be with "is" a…
deathbywedgie May 4, 2022
9441d13
removed generic TypeVar T as it currently has no impact and serves on…
deathbywedgie May 5, 2022
4ce64fe
previously specified the List (uppercase) type, but it is frequently …
deathbywedgie May 5, 2022
f75f98d
should raise ValueError instead of a generic Exception
deathbywedgie May 5, 2022
448c38a
fixed a typo in the function name
deathbywedgie May 6, 2022
3a34c85
minor: simplifying logic
deathbywedgie May 6, 2022
c366143
split requirements.txt so that it only calls for packages required by…
deathbywedgie May 6, 2022
073d0ed
correcting type definition: "allow_primitives" is a boolean, not a st…
deathbywedgie May 6, 2022
857cf1a
Fixed a typo in a variable name
deathbywedgie May 6, 2022
190f08b
setting "raw" strings for regex patterns to avoid warnings and proble…
deathbywedgie May 6, 2022
1b5fefb
converting to "raw" strings for regex patterns
deathbywedgie May 6, 2022
8ce20a8
corrected a typo
deathbywedgie May 6, 2022
9ff51e3
should raise appropriate exceptions instead of generic exceptions
deathbywedgie May 6, 2022
53a6e68
fixed typos in variable names
deathbywedgie May 6, 2022
bd4834f
removed arbitrary backslashes: it is not necessary to escape a forwar…
deathbywedgie May 6, 2022
8e05135
renamed a variable: should not use the name of built-in methods, in t…
deathbywedgie May 6, 2022
2ed1344
TypedDict only serves to cause type hint warnings here, so changed to…
deathbywedgie May 6, 2022
0fccc93
further cleanup: no point in the IsMobileNumberOptions class when dic…
deathbywedgie May 6, 2022
183bc13
fixed a typo in a local variable name
deathbywedgie May 6, 2022
ce0f273
fixing more typos
deathbywedgie May 6, 2022
58e6419
typo in method name "sufix," and it does not appear to be used anywhe…
deathbywedgie May 6, 2022
a47724d
it is not safe practice to overwrite a method from a base/inherited c…
deathbywedgie May 6, 2022
eee15a3
"search" method is redeclared without being used first, so the first …
deathbywedgie May 6, 2022
aa3854e
nit: minor PEP 8 standard that function names should be lowercase, an…
deathbywedgie May 6, 2022
9ee03b7
Passing input of any type other than str, int, float, dict, or list c…
deathbywedgie May 6, 2022
90e19e8
Missing "staticmethod" decorator, so pattern would instead be treated…
deathbywedgie May 6, 2022
1701811
Instead of comparing types to their string names, it is safer and muc…
deathbywedgie May 7, 2022
c380136
Merge branch 'theteladras:main' into chore/PEP8_E711_none_and_boolean
May 7, 2022
2bff6c3
merged and resolved a conflict from remote/main, and bumped patch ver…
deathbywedgie May 11, 2022
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
12 changes: 6 additions & 6 deletions pyvalidator/alpha.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@
'sr-RS@latin': '^[A-ZČĆŽŠĐ]+$',
'sr-RS': '^[А-ЯЂЈЉЊЋЏ]+$',
'sv-SE': '^[A-ZÅÄÖ]+$',
'th-TH': '^[ก-๐\s]+$',
'th-TH': r'^[ก-๐\s]+$',
'tr-TR': '^[A-ZÇĞİıÖŞÜ]+$',
'uk-UA': '^[А-ЩЬЮЯЄIЇҐі]+$',
'vi-VN': '^[A-ZÀÁẠẢÃÂẦẤẬẨẪĂẰẮẶẲẴĐÈÉẸẺẼÊỀẾỆỂỄÌÍỊỈĨÒÓỌỎÕÔỒỐỘỔỖƠỜỚỢỞỠÙÚỤỦŨƯỪỨỰỬỮỲÝỴỶỸ]+$',
'ku-IQ': '^[ئابپتجچحخدرڕزژسشعغفڤقکگلڵمنوۆھەیێيطؤثآإأكضصةظذ]+$',
'ar': '^[ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+',
'he': '^[א-ת]+',
'fa': '^[\'آاءأؤئبپتثجچحخدذرزژسشصضطظعغفقکگلمنوهةی\']+$',
'hi-IN': '^[\u0900-\u0961]+[\u0972-\u097F]*$',
'fa': r'^[\'آاءأؤئبپتثجچحخدذرزژسشصضطظعغفقکگلمنوهةی\']+$',
'hi-IN': r'^[\u0900-\u0961]+[\u0972-\u097F]*$',
}

alphanumeric = {
Expand All @@ -58,15 +58,15 @@
'sr-RS@latin': '^[0-9A-ZČĆŽŠĐ]+$',
'sr-RS': '^[0-9А-ЯЂЈЉЊЋЏ]+$',
'sv-SE': '^[0-9A-ZÅÄÖ]+$',
'th-TH': '^[ก-๙\s]+$',
'th-TH': r'^[ก-๙\s]+$',
'tr-TR': '^[0-9A-ZÇĞİıÖŞÜ]+$',
'uk-UA': '^[0-9А-ЩЬЮЯЄIЇҐі]+$',
'ku-IQ': '^[٠١٢٣٤٥٦٧٨٩0-9ئابپتجچحخدرڕزژسشعغفڤقکگلڵمنوۆھەیێيطؤثآإأكضصةظذ]+$',
'vi-VN': '^[0-9A-ZÀÁẠẢÃÂẦẤẬẨẪĂẰẮẶẲẴĐÈÉẸẺẼÊỀẾỆỂỄÌÍỊỈĨÒÓỌỎÕÔỒỐỘỔỖƠỜỚỢỞỠÙÚỤỦŨƯỪỨỰỬỮỲÝỴỶỸ]+$',
'ar': '^[٠١٢٣٤٥٦٧٨٩0-9ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+',
'he': '^[0-9א-ת]+',
'fa': '^[\'0-9آاءأؤئبپتثجچحخدذرزژسشصضطظعغفقکگلمنوهةی۱۲۳۴۵۶۷۸۹۰\']+$',
'hi-IN': '^[\u0900-\u0963]+[\u0966-\u097F]*$',
'fa': r'^[\'0-9آاءأؤئبپتثجچحخدذرزژسشصضطظعغفقکگلمنوهةی۱۲۳۴۵۶۷۸۹۰\']+$',
'hi-IN': r'^[\u0900-\u0963]+[\u0966-\u097F]*$',
}

decimal = {
Expand Down
6 changes: 3 additions & 3 deletions pyvalidator/is_alpha.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
def is_alpha(input, locale='en-US', options={}):
input = assert_string(input)

if locale == None:
if locale is None:
locale = 'en-US'

if 'ignore' in options and options['ignore']:
Expand All @@ -16,13 +16,13 @@ def is_alpha(input, locale='en-US', options={}):

input = input.sub(pattern, '')
else:
raise Exception('ignore should be instance of a String or RegExp')
raise TypeError('ignore should be instance of a String or RegExp')

if locale in alpha:
pattern = RegEx(alpha[locale], 'i')
return pattern.match(input)

raise Exception("Invalid locale {}".format(locale))
raise ValueError("Invalid locale {}".format(locale))


locales = list(alpha.keys())
2 changes: 1 addition & 1 deletion pyvalidator/is_ascii.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@


def is_ascii(input: str) -> bool:
pattern = RegEx("^[\x00-\x7F]+$")
pattern = RegEx(r"^[\x00-\x7F]+$")
input = assert_string(input)
return pattern.match(input)
4 changes: 2 additions & 2 deletions pyvalidator/is_base64.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
def is_base64(input: str, options={}) -> bool:
assert_string(input)

not_base64 = RegEx("[^A-Z0-9+\/=]", "i")
url_safe_base64 = RegEx("^[A-Z0-9_\-]*$", "i")
not_base64 = RegEx(r"[^A-Z0-9+/=]", "i")
url_safe_base64 = RegEx(r"^[A-Z0-9_\-]*$", "i")

options = merge(options, default_base64_options)
input_length = len(input)
Expand Down
2 changes: 1 addition & 1 deletion pyvalidator/is_byte_length.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ def is_byte_length(input: str, options={}) -> bool:
input_length = len(split_input) - 1

return input_length >= options["min"] and (
options["max"] == None or input_length <= options["max"]
options["max"] is None or input_length <= options["max"]
)
20 changes: 10 additions & 10 deletions pyvalidator/is_credit_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
def is_credit_card(input: str) -> bool:
input = assert_string(input)

credit_card = RegEx("^(?:4[0-9]{12}(?:[0-9]{3,6})?|5[1-5][0-9]{14}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12,15}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11}|6[27][0-9]{14}|^(81[0-9]{14,17}))$")
sanetization_pattern = RegEx("[- ]+", 'g')
credit_card = RegEx(r"^(?:4[0-9]{12}(?:[0-9]{3,6})?|5[1-5][0-9]{14}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12,15}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11}|6[27][0-9]{14}|^(81[0-9]{14,17}))$")
sanitization_pattern = RegEx("[- ]+", 'g')

sanitized = input.sub(sanetization_pattern, '')
sanitized = input.sub(sanitization_pattern, '')

if not credit_card.match(sanitized):
return False

sum = 0
_sum = 0
should_double = False
reversed_sanetized_input = sanitized[::-1]
reversed_sanitized_input = sanitized[::-1]

for digit in reversed_sanetized_input:
for digit in reversed_sanitized_input:
if not is_number(digit):
return False

Expand All @@ -27,11 +27,11 @@ def is_credit_card(input: str) -> bool:
if should_double:
tmp_num = tmp_num * 2
if tmp_num >= 10:
sum += ((tmp_num % 10) + 1)
_sum += ((tmp_num % 10) + 1)
else:
sum += tmp_num
_sum += tmp_num
else:
sum += tmp_num
_sum += tmp_num
should_double = not should_double

return bool(sanitized if (sum % 10) == 0 else False)
return bool(sanitized if (_sum % 10) == 0 else False)
16 changes: 8 additions & 8 deletions pyvalidator/is_currency.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@


def currency_regex(options):
decimal_digits = "\d{" + str(options["digits_after_decimal"][0]) + "}"
decimal_digits = r"\d{" + str(options["digits_after_decimal"][0]) + "}"
for index, digit in enumerate(options["digits_after_decimal"]):
if index != 0:
decimal_digits = "{}|\d{}{}{}".format(decimal_digits, '{', digit, '}')
decimal_digits = r"{}|\d{}{}{}".format(decimal_digits, '{', digit, '}')

def __match(x):
return "\\{}".format(x.group(0))

symbol = "({}){}".format(RegEx.sub("\W", __match, options["symbol"]), '' if options["require_symbol"] else '?')
symbol = "({}){}".format(RegEx.sub(r"\W", __match, options["symbol"]), '' if options["require_symbol"] else '?')
negative = '-?'
whole_dollar_amount_without_sep = '[1-9]\d*'
whole_dollar_amount_with_sep = "[1-9]\d{{0,2}}({}\d{{3}})*".format(options["thousands_separator"])
whole_dollar_amount_without_sep = r'[1-9]\d*'
whole_dollar_amount_with_sep = r"[1-9]\d{{0,2}}({}\d{{3}})*".format(options["thousands_separator"])
valid_whole_dollar_amounts = [
'0',
whole_dollar_amount_without_sep,
whole_dollar_amount_with_sep
]
whole_dollar_amount = "({})?".format(join(valid_whole_dollar_amounts, '|'))
decimal_amount = "(\{}({})){}".format(options["decimal_separator"], decimal_digits, '' if options["require_decimal"] else '?')
decimal_amount = r"(\{}({})){}".format(options["decimal_separator"], decimal_digits, '' if options["require_decimal"] else '?')
pattern = "{}{}".format(
whole_dollar_amount,
decimal_amount if (options["allow_decimal"] or options["require_decimal"]) else ''
Expand All @@ -36,7 +36,7 @@ def __match(x):
pattern = negative + pattern

if options["allow_negative_sign_placeholder"]:
pattern = "( (?!\-))?" + pattern
pattern = r"( (?!\-))?" + pattern
elif options["allow_space_after_symbol"]:
pattern = " ?" + pattern
elif options["allow_space_after_digits"]:
Expand All @@ -53,7 +53,7 @@ def __match(x):
elif not (options["negative_sign_before_digits"] and options["negative_sign_after_digits"]):
pattern = negative + pattern

return RegEx("^(?!-? )(?=.*\d){}$".format(pattern))
return RegEx(r"^(?!-? )(?=.*\d){}$".format(pattern))


default_currency_options = {
Expand Down
6 changes: 3 additions & 3 deletions pyvalidator/is_data_uri.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
def is_data_uri(input: str) -> bool:
assert_string(input)

valid_media_type = RegEx("^[a-z]+\/[a-z0-9\-\+]+$", 'i')
valid_attribute = RegEx("^[a-z\-]+=[a-z0-9\-]+$", 'i')
valid_data = RegEx("^[a-z0-9!\$&'\(\)\*\+,;=\-\._~:@\/\?%\s]*$", 'i')
valid_media_type = RegEx(r"^[a-z]+/[a-z0-9\-\+]+$", 'i')
valid_attribute = RegEx(r"^[a-z\-]+=[a-z0-9\-]+$", 'i')
valid_data = RegEx(r"^[a-z0-9!\$&'\(\)\*\+,;=\-\._~:@/\?%\s]*$", 'i')

data = input.split(',')

Expand Down
18 changes: 9 additions & 9 deletions pyvalidator/is_date.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ def zip(date_list: ListT[str], format_list: ListT[str]) -> ListT[Tuple[str, str]
def is_date(input: str, options: IsDateOptions = {}) -> bool:
input = assert_string(input)

date_format_pattern = RegEx(r"(^(y{4}|y{2})[|:;,.\/-](m{1,2})[|:;,.\/-](d{1,2})$)|(^(m{1,2})[|:;,.\/-](d{1,2})[|:;,.\/-]((y{4}|y{2})$))|(^(d{1,2})[|:;,.\/-](m{1,2})[|:;,.\/-]((y{4}|y{2})$))", 'i')
date_format_pattern = RegEx(r"(^(y{4}|y{2})[|:;,./-](m{1,2})[|:;,./-](d{1,2})$)|(^(m{1,2})[|:;,./-](d{1,2})[|:;,./-]((y{4}|y{2})$))|(^(d{1,2})[|:;,./-](m{1,2})[|:;,./-]((y{4}|y{2})$))", 'i')

options = merge(options, __default_options)

format = String(options['format'])

if not date_format_pattern.match(format):
raise Exception('Not supported format provided: ', format)
raise ValueError('Not supported format provided: ', format)

format_delimiter: Union[str, None] = List(options['delimiters']).find(lambda delimiter, _: delimiter in format)

Expand All @@ -80,20 +80,20 @@ def is_date(input: str, options: IsDateOptions = {}) -> bool:
if not input_delimiter:
return False

format = format if options['strict_mode'] else format.sub("\{}".format(input_delimiter), '/')
input = input if options['strict_mode'] else input.sub("\{}".format(input_delimiter), '/')
format = format if options['strict_mode'] else format.sub(r"\{}".format(input_delimiter), '/')
input = input if options['strict_mode'] else input.sub(r"\{}".format(input_delimiter), '/')

format_tupples = zip(
format_tuples = zip(
input.split(date_delimiter),
format.lower().split(date_delimiter)
)

date_dict = {}

for format_tupple in format_tupples:
if len(format_tupple[0]) != len(format_tupple[1]):
for format_tuple in format_tuples:
if len(format_tuple[0]) != len(format_tuple[1]):
return False
format_char = format_tupple[1][0]
date_dict[format_char] = format_tupple[0]
format_char = format_tuple[1][0]
date_dict[format_char] = format_tuple[0]

return bool(to_date("{}/{}/{}".format(date_dict['m'], date_dict['d'], date_dict['y'])))
4 changes: 2 additions & 2 deletions pyvalidator/is_decimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def decimal_regexp(options):
local_decimal = decimal[local]
decimal_digits = options["decimal_digits"]
require_decimal = '' if options["force_decimal"] else '?'
regex = "^[-+]?([0-9]+)?(\{}[0-9]{{".format(local_decimal) + "{}}}){}$".format(decimal_digits, require_decimal)
regex = r"^[-+]?([0-9]+)?(\{}[0-9]{{".format(local_decimal) + "{}}}){}$".format(decimal_digits, require_decimal)
return RegEx(regex)


Expand All @@ -31,7 +31,7 @@ def is_decimal(input: str, options={}) -> bool:
options = merge(options, default_decimal_options)

if options["locale"] not in decimal:
raise Exception("Invalid locale '{}'".format(options["locale"]))
raise ValueError("Invalid locale '{}'".format(options["locale"]))

without_white_space = input.sub(" ", '')
return includesNot(blacklist, without_white_space) and bool(decimal_regexp(options).match(input))
2 changes: 1 addition & 1 deletion pyvalidator/is_divisible_by.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@

def is_divisible_by(input: str, num: Union[int, float, str]) -> bool:
assert_string(input)
if to_float(input) != None and to_int(num) != None:
if to_float(input) is not None and to_int(num) is not None:
return (to_float(input) % to_int(num)) == 0
return False
2 changes: 1 addition & 1 deletion pyvalidator/is_ean.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def reducer(acc, partial_sum):
def is_ean(input: str) -> bool:
input = assert_string(input)

valid_ean_regex = RegEx("^(\d{8}|\d{13}|\d{14})$")
valid_ean_regex = RegEx(r"^(\d{8}|\d{13}|\d{14})$")

actual_check_digit = input.slice(-1)
if not is_number(actual_check_digit):
Expand Down
14 changes: 7 additions & 7 deletions pyvalidator/is_email.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import TypedDict
from typing import TypedDict, Union

from .is_byte_length import is_byte_length
from .is_fqdn import is_fqdn
Expand All @@ -20,7 +20,7 @@ class IsEmailOptions(TypedDict):
domain_specific_validation: bool
allow_ip_domain: bool
blacklisted_chars: str
host_blacklist: List
host_blacklist: Union[List, list]


default_email_options: IsEmailOptions = {
Expand Down Expand Up @@ -67,15 +67,15 @@ def is_email(input: str, options: IsEmailOptions = {}) -> bool:
options = merge(options, default_email_options)

split_name_address = r"^([^\x00-\x1F\x7F-\x9F]+)<"
email_user_part = r"^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$"
email_user_part = r"^[a-z\d!#\$%&'\*\+\-/=\?\^_`{\|}~]+$"
gmail_user_part = r"^[a-z\d]+$"
quoted_email_user = r"^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$"
email_user_utf8_part = r"^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$"
email_user_utf8_part = r"^[a-z\d!#\$%&'\*\+\-/=\?\^_`{\|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$"
quoted_email_user_utf8 = r"^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*$"
default_max_email_length = 254

if options["require_display_name"] or options["allow_display_name"]:
display_email = input.findMatches(split_name_address, 'i')
display_email = input.find_matches(split_name_address, 'i')
if display_email:
display_name = String(display_email[0])

Expand Down Expand Up @@ -105,7 +105,7 @@ def is_email(input: str, options: IsEmailOptions = {}) -> bool:
user = user.lower()
username = String(user.split('+')[0])

if not is_byte_length(username.sub(RegEx('\.', 'g'), ''), {"min": 6, "max": 30}):
if not is_byte_length(username.sub(RegEx(r'\.', 'g'), ''), {"min": 6, "max": 30}):
return False

user_parts = username.split('.')
Expand Down Expand Up @@ -149,7 +149,7 @@ def is_email(input: str, options: IsEmailOptions = {}) -> bool:
return False

if options["blacklisted_chars"]:
if user.findMatches(RegEx("[" + options["blacklisted_chars"] + "]+", 'g')):
if user.find_matches(RegEx("[" + options["blacklisted_chars"] + "]+", 'g')):
return False

return True
36 changes: 18 additions & 18 deletions pyvalidator/is_emoji.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@
from .utils.assert_string import assert_string
from .utils.merge import merge

empji_patterns = (
emoji_patterns = (
"^["
"\U0001F1E0-\U0001F1FF" # flags (iOS)
"\U0001F300-\U0001F5FF" # symbols & pictographs
"\U0001F600-\U0001F64F" # emoticons
"\U0001F680-\U0001F6FF" # transport & map symbols
"\U0001F700-\U0001F77F" # alchemical symbols
"\U0001F780-\U0001F7FF" # Geometric Shapes Extended
"\U0001F800-\U0001F8FF" # Supplemental Arrows-C
"\U0001F900-\U0001F9FF" # Supplemental Symbols and Pictographs
"\U0001FA00-\U0001FA6F" # Chess Symbols
"\U0001FA70-\U0001FAFF" # Symbols and Pictographs Extended-A
"\U00002702-\U000027B0" # Dingbats
r"\U0001F1E0-\U0001F1FF" # flags (iOS)
r"\U0001F300-\U0001F5FF" # symbols & pictographs
r"\U0001F600-\U0001F64F" # emoticons
r"\U0001F680-\U0001F6FF" # transport & map symbols
r"\U0001F700-\U0001F77F" # alchemical symbols
r"\U0001F780-\U0001F7FF" # Geometric Shapes Extended
r"\U0001F800-\U0001F8FF" # Supplemental Arrows-C
r"\U0001F900-\U0001F9FF" # Supplemental Symbols and Pictographs
r"\U0001FA00-\U0001FA6F" # Chess Symbols
r"\U0001FA70-\U0001FAFF" # Symbols and Pictographs Extended-A
r"\U00002702-\U000027B0" # Dingbats
"]$"
)

Expand All @@ -37,25 +37,25 @@ def is_emoji(input: str, options: IsEmojiOptions = {}) -> bool:

def is_flag_emoji(c):
return (
"\U0001F1E6\U0001F1E8" <= c <= "\U0001F1FF\U0001F1FC"
r"\U0001F1E6\U0001F1E8" <= c <= r"\U0001F1FF\U0001F1FC"
or (
c in [
"\U0001F3F4\U000e0067\U000e0062\U000e0065\U000e006e\U000e0067\U000e007f",
"\U0001F3F4\U000e0067\U000e0062\U000e0073\U000e0063\U000e0074\U000e007f",
"\U0001F3F4\U000e0067\U000e0062\U000e0077\U000e006c\U000e0073\U000e007f"
r"\U0001F3F4\U000e0067\U000e0062\U000e0065\U000e006e\U000e0067\U000e007f",
r"\U0001F3F4\U000e0067\U000e0062\U000e0073\U000e0063\U000e0074\U000e007f",
r"\U0001F3F4\U000e0067\U000e0062\U000e0077\U000e006c\U000e0073\U000e007f"
]
)
)

if options["omit_rule"] != None:
if options["omit_rule"] is not None:
input = input.sub(options["omit_rule"], '')

if not input.length:
return False

for char in input:
char = String(char)
if not (char.match(empji_patterns) or is_flag_emoji(char)):
if not (char.match(emoji_patterns) or is_flag_emoji(char)):
return False

return True
2 changes: 1 addition & 1 deletion pyvalidator/is_even.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
def is_even(input: Union[int, str]) -> bool:
input = to_int(input)

if input == None:
if input is None:
return False

return not bool(input % 2)
Loading