This commit is contained in:
2025-07-14 12:24:05 -03:00
parent 51cc1bbbb5
commit 98cd751ed9
7 changed files with 55 additions and 72 deletions

View File

@@ -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)