Skip to content

Commit cee8d54

Browse files
TheDrunkenBearyozachar
authored andcommitted
feat(validators): add Mir card number validation
1 parent 7c97eca commit cee8d54

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/validators/card.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,25 @@ def discover(value: str, /):
192192
"""
193193
pattern = re.compile(r"^(60|64|65)")
194194
return card_number(value) and len(value) == 16 and pattern.match(value)
195+
196+
197+
@validator
198+
def mir(value: str, /):
199+
"""Return whether or not given value is a valid Mir card number.
200+
201+
Examples:
202+
>>> mir('2200123456789012')
203+
# Output: True
204+
>>> mir('4242424242424242')
205+
# Output: ValidationError(func=mir, args={'value': '4242424242424242'})
206+
207+
Args:
208+
value:
209+
Mir card number string to validate.
210+
211+
Returns:
212+
(Literal[True]): If `value` is a valid Mir card number.
213+
(ValidationError): If `value` is an invalid Mir card number.
214+
"""
215+
pattern = re.compile(r"^(220[0-4])")
216+
return card_number(value) and len(value) == 16 and pattern.match(value)

0 commit comments

Comments
 (0)