Padronizando CPF CNPJ
This commit is contained in:
parent
2249c95b39
commit
227c90c5b6
1 changed files with 9 additions and 1 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
from datetime import date
|
from datetime import date
|
||||||
|
|
||||||
from pydantic import AliasChoices, BaseModel, ConfigDict, Field, validate_call
|
from pydantic import AliasChoices, BaseModel, ConfigDict, Field, field_validator, validate_call
|
||||||
|
|
||||||
|
|
||||||
class NotasHolmesProperties(BaseModel):
|
class NotasHolmesProperties(BaseModel):
|
||||||
|
|
@ -33,6 +33,14 @@ class NotasHolmesProperties(BaseModel):
|
||||||
vencimento_11: date | None = Field(None, validation_alias=AliasChoices("vencimento_11", "Vencimento 11"))
|
vencimento_11: date | None = Field(None, validation_alias=AliasChoices("vencimento_11", "Vencimento 11"))
|
||||||
vencimento_12: date | None = Field(None, validation_alias=AliasChoices("vencimento_12", "Vencimento 12"))
|
vencimento_12: date | None = Field(None, validation_alias=AliasChoices("vencimento_12", "Vencimento 12"))
|
||||||
|
|
||||||
|
@field_validator('cpf_cnpj')
|
||||||
|
@classmethod
|
||||||
|
def so_numeros(cls, valor: str | None) -> str | None:
|
||||||
|
# Holmes manda formatado (35.764.054/0001-08); grava só os dígitos
|
||||||
|
if valor is None:
|
||||||
|
return None
|
||||||
|
return ''.join(c for c in valor if c.isdigit()) or None
|
||||||
|
|
||||||
class NotasHolmesInput(BaseModel):
|
class NotasHolmesInput(BaseModel):
|
||||||
id: str
|
id: str
|
||||||
properties: NotasHolmesProperties
|
properties: NotasHolmesProperties
|
||||||
Loading…
Add table
Add a link
Reference in a new issue