You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1018 B
44 lines
1018 B
from schwifty import IBAN, BIC |
|
import datetime |
|
from validator_collection import validators, errors |
|
|
|
|
|
def valid_iban(field, value, error): |
|
try: |
|
IBAN(value) |
|
return True |
|
except ValueError: |
|
error(field, 'not a valid IBAN') |
|
|
|
|
|
def valid_bic(field, value, error): |
|
try: |
|
BIC(value) |
|
return True |
|
except ValueError: |
|
error(field, 'not a valid BIC') |
|
|
|
|
|
def iso_date(field, value, error): |
|
try: |
|
datetime.datetime.strptime(value, "%Y-%m-%d") |
|
return True |
|
except ValueError: |
|
error(field, 'not a valid ISO 8601 date') |
|
|
|
|
|
def valid_money_amount(field, value, error): |
|
try: |
|
# value is string, check formatting by parsing as float |
|
float(value) |
|
return True |
|
except (ValueError, TypeError): |
|
error(field, 'not a valid money value') |
|
|
|
|
|
def valid_email(field, value, error): |
|
try: |
|
validators.email(value) |
|
return True |
|
except errors.InvalidEmailError: |
|
error(field, 'not a valid email')
|
|
|