validator bibliothek statt eigenen regex für email validation
This commit is contained in:
parent
fee14d9349
commit
0082ee2bad
3 changed files with 12 additions and 3 deletions
|
@ -66,7 +66,7 @@ def validate(entity):
|
||||||
'email': {
|
'email': {
|
||||||
'type': 'string',
|
'type': 'string',
|
||||||
'required': True,
|
'required': True,
|
||||||
'regex': '^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+$'},
|
'check_with': valid_email},
|
||||||
'fullname': {
|
'fullname': {
|
||||||
'type': 'string',
|
'type': 'string',
|
||||||
'required': True},
|
'required': True},
|
||||||
|
|
|
@ -2,4 +2,5 @@ tornado==6.0.4
|
||||||
isodate==0.6.0
|
isodate==0.6.0
|
||||||
pytest==5.4.1
|
pytest==5.4.1
|
||||||
schwifty==2020.11.0
|
schwifty==2020.11.0
|
||||||
Cerberus==1.3.2
|
Cerberus==1.3.2
|
||||||
|
validator-collection==1.5.0
|
|
@ -1,5 +1,6 @@
|
||||||
from schwifty import IBAN, BIC
|
from schwifty import IBAN, BIC
|
||||||
import datetime
|
import datetime
|
||||||
|
from validator_collection import validators, errors
|
||||||
|
|
||||||
def valid_iban(field, value, error):
|
def valid_iban(field, value, error):
|
||||||
try:
|
try:
|
||||||
|
@ -28,4 +29,11 @@ def valid_money_amount(field, value, error):
|
||||||
float(value)
|
float(value)
|
||||||
return True
|
return True
|
||||||
except (ValueError, TypeError):
|
except (ValueError, TypeError):
|
||||||
error(field, 'not a valid money value')
|
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')
|
Loading…
Reference in a new issue