fix user
This commit is contained in:
@@ -22,13 +22,15 @@ else:
|
||||
>>> User(name='Sérgio R Siqueira ').name
|
||||
'Sérgio R Siqueira'
|
||||
|
||||
>>> User(name=' Sérgio R Siqueira ').name
|
||||
>>> User(name=' Sérgio R Siqueira ').name
|
||||
'Sérgio R Siqueira'
|
||||
|
||||
|
||||
>>> User(name='Siqueira')
|
||||
>>> User(name='Siqueira') # doctest: +ELLIPSIS
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
pydantic_core._pydantic_core.ValidationError: 1 validation error for User
|
||||
...
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
@@ -42,6 +44,7 @@ else:
|
||||
@classmethod
|
||||
def _validate(cls, __input_value: str) -> str:
|
||||
name = ftfy.fix_text(__input_value.strip())
|
||||
name = ' '.join(name.split())
|
||||
|
||||
if ' ' not in name:
|
||||
raise ValueError('Invalid name.')
|
||||
@@ -67,10 +70,7 @@ class PaymentCardValidation:
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
pydantic_core._pydantic_core.ValidationError: 1 validation error for CreditCard
|
||||
exp
|
||||
Value error, month must be in 1..12 [type=value_error, input_value='20/23', input_type=str]
|
||||
For further information visit https://errors.pydantic.dev/2.4/v/value_error
|
||||
|
||||
...
|
||||
|
||||
>>> CreditCard(exp='12/23')
|
||||
CreditCard(exp=datetime.date(2023, 12, 1))
|
||||
@@ -175,4 +175,4 @@ else:
|
||||
if __name__ == '__main__':
|
||||
import doctest
|
||||
|
||||
doctest.testmod()
|
||||
doctest.testmod(optionflags=doctest.ELLIPSIS)
|
||||
|
||||
Reference in New Issue
Block a user