spei-python 1.0.3__tar.gz → 1.0.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {spei_python-1.0.3 → spei_python-1.0.5}/PKG-INFO +3 -5
- {spei_python-1.0.3 → spei_python-1.0.5}/pyproject.toml +6 -8
- {spei_python-1.0.3 → spei_python-1.0.5}/spei/checksum/generator.py +5 -7
- {spei_python-1.0.3 → spei_python-1.0.5}/spei/errors/spei.py +1 -0
- {spei_python-1.0.3 → spei_python-1.0.5}/spei/resources/cda.py +27 -11
- {spei_python-1.0.3 → spei_python-1.0.5}/spei/resources/orden.py +46 -40
- {spei_python-1.0.3 → spei_python-1.0.5}/spei/resources/payments.py +4 -4
- {spei_python-1.0.3 → spei_python-1.0.5}/spei/resources/respuesta.py +14 -7
- spei_python-1.0.5/spei/types/common.py +18 -0
- spei_python-1.0.3/spei/types/common.py +0 -41
- {spei_python-1.0.3 → spei_python-1.0.5}/README.md +0 -0
- {spei_python-1.0.3 → spei_python-1.0.5}/spei/README.md +0 -0
- {spei_python-1.0.3 → spei_python-1.0.5}/spei/__init__.py +0 -0
- {spei_python-1.0.3 → spei_python-1.0.5}/spei/cep_generator.py +0 -0
- {spei_python-1.0.3 → spei_python-1.0.5}/spei/checksum/__init__.py +0 -0
- {spei_python-1.0.3 → spei_python-1.0.5}/spei/checksum/factory.py +0 -0
- {spei_python-1.0.3 → spei_python-1.0.5}/spei/checksum/types.py +0 -0
- {spei_python-1.0.3 → spei_python-1.0.5}/spei/client.py +0 -0
- {spei_python-1.0.3 → spei_python-1.0.5}/spei/errors/__init__.py +0 -0
- {spei_python-1.0.3 → spei_python-1.0.5}/spei/errors/sice.py +0 -0
- {spei_python-1.0.3 → spei_python-1.0.5}/spei/exceptions.py +0 -0
- {spei_python-1.0.3 → spei_python-1.0.5}/spei/mappings.py +0 -0
- {spei_python-1.0.3 → spei_python-1.0.5}/spei/requests/__init__.py +0 -0
- {spei_python-1.0.3 → spei_python-1.0.5}/spei/requests/acuse.py +0 -0
- {spei_python-1.0.3 → spei_python-1.0.5}/spei/requests/cda.py +0 -0
- {spei_python-1.0.3 → spei_python-1.0.5}/spei/requests/orden.py +0 -0
- {spei_python-1.0.3 → spei_python-1.0.5}/spei/requests/respuesta.py +0 -0
- {spei_python-1.0.3 → spei_python-1.0.5}/spei/resources/__init__.py +0 -0
- {spei_python-1.0.3 → spei_python-1.0.5}/spei/resources/acuse.py +0 -0
- {spei_python-1.0.3 → spei_python-1.0.5}/spei/resources/ensesion.py +0 -0
- {spei_python-1.0.3 → spei_python-1.0.5}/spei/resources/mensaje.py +0 -0
- {spei_python-1.0.3 → spei_python-1.0.5}/spei/resources/validators.py +0 -0
- {spei_python-1.0.3 → spei_python-1.0.5}/spei/responses/__init__.py +0 -0
- {spei_python-1.0.3 → spei_python-1.0.5}/spei/responses/acuse.py +0 -0
- {spei_python-1.0.3 → spei_python-1.0.5}/spei/responses/orden.py +0 -0
- {spei_python-1.0.3 → spei_python-1.0.5}/spei/responses/respuesta.py +0 -0
- {spei_python-1.0.3 → spei_python-1.0.5}/spei/sice.py +0 -0
- {spei_python-1.0.3 → spei_python-1.0.5}/spei/types/__init__.py +0 -0
- {spei_python-1.0.3 → spei_python-1.0.5}/spei/types/sice.py +0 -0
- {spei_python-1.0.3 → spei_python-1.0.5}/spei/types/spei.py +0 -0
- {spei_python-1.0.3 → spei_python-1.0.5}/spei/utils.py +0 -0
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
2
|
Name: spei-python
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.5
|
|
4
4
|
Summary:
|
|
5
5
|
Author: tech
|
|
6
6
|
Author-email: tech@fondeadora.com
|
|
7
|
-
Requires-Python: >=3.
|
|
7
|
+
Requires-Python: >=3.11,<4.0
|
|
8
8
|
Classifier: Programming Language :: Python :: 3
|
|
9
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
10
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
11
9
|
Classifier: Programming Language :: Python :: 3.11
|
|
12
10
|
Classifier: Programming Language :: Python :: 3.12
|
|
13
11
|
Classifier: Programming Language :: Python :: 3.13
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "spei-python"
|
|
3
|
-
version = "1.0.
|
|
3
|
+
version = "1.0.5"
|
|
4
4
|
description = ""
|
|
5
5
|
authors = ["tech <tech@fondeadora.com>"]
|
|
6
6
|
readme = "README.md"
|
|
7
|
-
packages = [{include = "spei"}]
|
|
7
|
+
packages = [{ include = "spei" }]
|
|
8
8
|
|
|
9
9
|
[tool.poetry.dependencies]
|
|
10
|
-
python = ">=3.
|
|
10
|
+
python = ">=3.11,<4.0"
|
|
11
11
|
lxml = "^5.0.0"
|
|
12
12
|
pydantic = ">=1.10.17,<3"
|
|
13
13
|
requests = "^2.32.2"
|
|
@@ -32,12 +32,10 @@ build-backend = "poetry.core.masonry.api"
|
|
|
32
32
|
|
|
33
33
|
[tool.commitizen]
|
|
34
34
|
name = "cz_conventional_commits"
|
|
35
|
-
version = "1.0.
|
|
35
|
+
version = "1.0.5"
|
|
36
36
|
tag_format = "v$version"
|
|
37
37
|
bump_message = "bump: Semantic Release Bot: Release Version: $new_version 🤖🚀 [skip ci]"
|
|
38
|
-
version_files = [
|
|
39
|
-
"pyproject.toml:version",
|
|
40
|
-
]
|
|
38
|
+
version_files = ["pyproject.toml:version"]
|
|
41
39
|
|
|
42
40
|
[tool.black]
|
|
43
41
|
skip-string-normalization = true
|
|
@@ -46,4 +44,4 @@ line-length = 88
|
|
|
46
44
|
# this was added to fix the issue: Package docutils (0.21.post1) not found.
|
|
47
45
|
[[tool.poetry.source]]
|
|
48
46
|
name = "pypi-public"
|
|
49
|
-
url = "https://pypi.org/simple/"
|
|
47
|
+
url = "https://pypi.org/simple/"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from datetime import
|
|
1
|
+
from datetime import date
|
|
2
2
|
from decimal import Decimal
|
|
3
3
|
from typing import Optional, Tuple
|
|
4
4
|
|
|
@@ -19,12 +19,10 @@ class ChecksumGenerator(object):
|
|
|
19
19
|
low = amount_as_cents - (tens_of_millons * 10**9)
|
|
20
20
|
return high, low
|
|
21
21
|
|
|
22
|
-
def _fecha_to_bytearray(self, fecha_operacion:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
month = int.to_bytes(int(fecha_operacion_dt.month), 1, 'big')
|
|
27
|
-
year = int.to_bytes(int(fecha_operacion_dt.year), 2, 'big')
|
|
22
|
+
def _fecha_to_bytearray(self, fecha_operacion: date) -> bytearray:
|
|
23
|
+
day = int.to_bytes(int(fecha_operacion.day), 1, 'big')
|
|
24
|
+
month = int.to_bytes(int(fecha_operacion.month), 1, 'big')
|
|
25
|
+
year = int.to_bytes(int(fecha_operacion.year), 2, 'big')
|
|
28
26
|
|
|
29
27
|
return bytearray(day + month + year)
|
|
30
28
|
|
|
@@ -35,6 +35,7 @@ class CuentaOrdenanteCodigoError(str, Enum):
|
|
|
35
35
|
cuenta_ordenante_solo_ceros = 20
|
|
36
36
|
cuenta_ordenante_clabe_longitud_incorrecta = 21
|
|
37
37
|
cuenta_ordenante_tarjeta_longitud_incorrecta = 22
|
|
38
|
+
cuenta_ordenante_digito_verificador_incorrecto = 202
|
|
38
39
|
|
|
39
40
|
|
|
40
41
|
class IdentificacionCuentaOrdenanteCodigoError(str, Enum):
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
from datetime import date, datetime
|
|
1
2
|
from typing import Optional
|
|
2
3
|
|
|
3
4
|
from lxml import etree
|
|
@@ -5,6 +6,7 @@ from pydantic import BaseModel, ConfigDict
|
|
|
5
6
|
|
|
6
7
|
from spei import types
|
|
7
8
|
from spei.resources.validators import normalize_invalid_chars
|
|
9
|
+
from spei.types.common import InstitutionCode
|
|
8
10
|
from spei.utils import to_pascal_case, to_snake_case # noqa: WPS347
|
|
9
11
|
|
|
10
12
|
SOAP_NS = 'http://schemas.xmlsoap.org/soap/envelope/'
|
|
@@ -17,8 +19,8 @@ class CDA(BaseModel):
|
|
|
17
19
|
|
|
18
20
|
id: int
|
|
19
21
|
mensaje_id: int
|
|
20
|
-
op_fecha_oper:
|
|
21
|
-
op_fecha_abono:
|
|
22
|
+
op_fecha_oper: date
|
|
23
|
+
op_fecha_abono: date
|
|
22
24
|
op_hora_abono: int
|
|
23
25
|
|
|
24
26
|
op_cve_rastreo: str
|
|
@@ -81,7 +83,13 @@ class CDA(BaseModel):
|
|
|
81
83
|
|
|
82
84
|
for element in datos_cta.getchildren():
|
|
83
85
|
tag = to_snake_case(element.tag)
|
|
84
|
-
|
|
86
|
+
|
|
87
|
+
if tag not in cls.model_fields:
|
|
88
|
+
continue
|
|
89
|
+
|
|
90
|
+
if tag == 'op_fecha_oper':
|
|
91
|
+
cda_data[tag] = datetime.strptime(element.text, '%d%m%Y').date()
|
|
92
|
+
else:
|
|
85
93
|
cda_data[tag] = element.text
|
|
86
94
|
|
|
87
95
|
return cls(**cda_data)
|
|
@@ -91,18 +99,26 @@ class CDA(BaseModel):
|
|
|
91
99
|
etree.QName(ENVIO_PRAXIS_NS, 'datosCda'),
|
|
92
100
|
idCda=str(self.id),
|
|
93
101
|
idMensaje=str(self.mensaje_id),
|
|
102
|
+
attrib={},
|
|
94
103
|
nsmap={'env': ENVIO_PRAXIS_NS},
|
|
95
104
|
)
|
|
96
105
|
|
|
97
|
-
elements = self.
|
|
106
|
+
elements = self.model_dump(exclude_none=True, exclude={'id', 'mensaje_id'})
|
|
98
107
|
|
|
99
108
|
for element, value in elements.items(): # noqa: WPS110
|
|
100
|
-
if element in self.
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
109
|
+
if element not in self.model_fields:
|
|
110
|
+
continue
|
|
111
|
+
|
|
112
|
+
if 'op_fecha' in element:
|
|
113
|
+
value = value.strftime('%d%m%Y')
|
|
114
|
+
|
|
115
|
+
pascal_case_element = to_pascal_case(element)
|
|
116
|
+
subelement = etree.SubElement(
|
|
117
|
+
mensaje,
|
|
118
|
+
etree.QName(ENVIO_PRAXIS_NS, pascal_case_element),
|
|
119
|
+
attrib={},
|
|
120
|
+
nsmap=None,
|
|
121
|
+
)
|
|
122
|
+
subelement.text = normalize_invalid_chars(value)
|
|
107
123
|
|
|
108
124
|
return mensaje
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import re
|
|
2
|
+
from datetime import date, datetime
|
|
2
3
|
from typing import Any, Dict, Optional
|
|
3
4
|
|
|
4
5
|
from lxml import etree
|
|
@@ -7,6 +8,7 @@ from pydantic import BaseModel, ConfigDict, field_validator
|
|
|
7
8
|
|
|
8
9
|
from spei import types
|
|
9
10
|
from spei.resources.validators import normalize_invalid_chars
|
|
11
|
+
from spei.types.common import InstitutionCode
|
|
10
12
|
from spei.utils import to_camel_case, to_pascal_case, to_snake_case # noqa: WPS347
|
|
11
13
|
|
|
12
14
|
SOAP_NS = 'http://schemas.xmlsoap.org/soap/envelope/'
|
|
@@ -28,7 +30,7 @@ class Orden(BaseModel):
|
|
|
28
30
|
|
|
29
31
|
id: int
|
|
30
32
|
categoria: types.CategoriaOrdenPago
|
|
31
|
-
op_fecha_oper:
|
|
33
|
+
op_fecha_oper: date
|
|
32
34
|
op_folio: int
|
|
33
35
|
op_monto: str
|
|
34
36
|
op_tp_clave: types.TipoPagoOrdenPago
|
|
@@ -85,7 +87,7 @@ class Orden(BaseModel):
|
|
|
85
87
|
# original info
|
|
86
88
|
op_folio_ori: Optional[int] = None
|
|
87
89
|
paq_folio_ori: Optional[int] = None
|
|
88
|
-
op_fecha_oper_ori: Optional[
|
|
90
|
+
op_fecha_oper_ori: Optional[date] = None
|
|
89
91
|
op_rastreo_ori: Optional[str] = None
|
|
90
92
|
op_monto_intereses: Optional[float] = None
|
|
91
93
|
op_monto_ori: Optional[float] = None
|
|
@@ -105,7 +107,7 @@ class Orden(BaseModel):
|
|
|
105
107
|
op_cert_comer_env: Optional[int] = None
|
|
106
108
|
op_digito_ver_comer: Optional[int] = None
|
|
107
109
|
# karpay system info
|
|
108
|
-
op_fecha_cap: Optional[
|
|
110
|
+
op_fecha_cap: Optional[date] = None
|
|
109
111
|
op_folio_servidor: Optional[int] = None
|
|
110
112
|
op_usu_autoriza: Optional[str] = None
|
|
111
113
|
op_err_clave: Optional[types.CodigoError] = None
|
|
@@ -149,52 +151,50 @@ class Orden(BaseModel):
|
|
|
149
151
|
nsmap=None,
|
|
150
152
|
)
|
|
151
153
|
|
|
152
|
-
elements = self.
|
|
154
|
+
elements = self.model_dump(
|
|
153
155
|
exclude_none=True,
|
|
154
156
|
exclude={'id', 'categoria', 'op_ins_clave_ord'},
|
|
155
157
|
)
|
|
156
158
|
|
|
157
159
|
for element, value in elements.items(): # noqa: WPS110
|
|
158
|
-
if element in self.model_fields:
|
|
159
|
-
|
|
160
|
-
subelement = etree.SubElement(
|
|
161
|
-
ordenpago,
|
|
162
|
-
'OpInsClave',
|
|
163
|
-
attrib={},
|
|
164
|
-
nsmap=None,
|
|
165
|
-
)
|
|
166
|
-
subelement.text = str(value)
|
|
167
|
-
continue
|
|
168
|
-
|
|
169
|
-
if element == 'op_firma_dig': # Lower case o in op
|
|
170
|
-
subelement = etree.SubElement(
|
|
171
|
-
ordenpago,
|
|
172
|
-
'opFirmaDig',
|
|
173
|
-
attrib={},
|
|
174
|
-
nsmap=None,
|
|
175
|
-
)
|
|
176
|
-
subelement.text = str(value)
|
|
177
|
-
continue
|
|
178
|
-
|
|
179
|
-
text = normalize_invalid_chars(str(value))
|
|
180
|
-
|
|
181
|
-
if element in _CAMEL_CASE_FIELDS:
|
|
182
|
-
subelement = etree.SubElement(
|
|
183
|
-
ordenpago,
|
|
184
|
-
to_camel_case(element),
|
|
185
|
-
attrib={},
|
|
186
|
-
nsmap=None,
|
|
187
|
-
)
|
|
188
|
-
subelement.text = text
|
|
189
|
-
continue
|
|
160
|
+
if element not in self.model_fields:
|
|
161
|
+
continue
|
|
190
162
|
|
|
163
|
+
if element == 'op_ins_clave_ben':
|
|
191
164
|
subelement = etree.SubElement(
|
|
192
165
|
ordenpago,
|
|
193
|
-
|
|
166
|
+
'OpInsClave',
|
|
194
167
|
attrib={},
|
|
195
168
|
nsmap=None,
|
|
196
169
|
)
|
|
197
|
-
subelement.text =
|
|
170
|
+
subelement.text = str(value)
|
|
171
|
+
continue
|
|
172
|
+
|
|
173
|
+
if element == 'op_firma_dig': # Lower case o in op
|
|
174
|
+
subelement = etree.SubElement(
|
|
175
|
+
ordenpago,
|
|
176
|
+
'opFirmaDig',
|
|
177
|
+
attrib={},
|
|
178
|
+
nsmap=None,
|
|
179
|
+
)
|
|
180
|
+
subelement.text = str(value)
|
|
181
|
+
continue
|
|
182
|
+
|
|
183
|
+
if 'op_fecha' in element:
|
|
184
|
+
value = value.strftime('%Y%m%d')
|
|
185
|
+
|
|
186
|
+
tag = (
|
|
187
|
+
to_camel_case(element)
|
|
188
|
+
if element in _CAMEL_CASE_FIELDS
|
|
189
|
+
else to_pascal_case(element)
|
|
190
|
+
)
|
|
191
|
+
subelement = etree.SubElement(
|
|
192
|
+
ordenpago,
|
|
193
|
+
tag,
|
|
194
|
+
attrib={},
|
|
195
|
+
nsmap=None,
|
|
196
|
+
)
|
|
197
|
+
subelement.text = normalize_invalid_chars(str(value))
|
|
198
198
|
|
|
199
199
|
return ordenpago
|
|
200
200
|
|
|
@@ -232,5 +232,11 @@ class Orden(BaseModel):
|
|
|
232
232
|
orden_data['op_firma_dig'] = stripped
|
|
233
233
|
return
|
|
234
234
|
|
|
235
|
-
if tag in cls.
|
|
236
|
-
|
|
235
|
+
if tag not in cls.model_fields:
|
|
236
|
+
return
|
|
237
|
+
|
|
238
|
+
if 'op_fecha' in tag:
|
|
239
|
+
orden_data[tag] = datetime.strptime(stripped, '%Y%m%d').date()
|
|
240
|
+
return
|
|
241
|
+
|
|
242
|
+
orden_data[tag] = stripped
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# mypy: disable-error-code="override"
|
|
2
2
|
|
|
3
|
+
from datetime import date
|
|
3
4
|
from typing import Optional
|
|
4
5
|
|
|
5
6
|
from spei import types
|
|
6
7
|
from spei.resources.orden import Orden
|
|
7
|
-
from spei.types.common import DateInt
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
class TerceroATercero(Orden):
|
|
@@ -326,7 +326,7 @@ class DevolucionExtemporaneaNoAcreditada(Orden):
|
|
|
326
326
|
op_folio_ori: Optional[int] = None
|
|
327
327
|
paq_folio_ori: Optional[int] = None
|
|
328
328
|
|
|
329
|
-
op_fecha_oper_ori:
|
|
329
|
+
op_fecha_oper_ori: date
|
|
330
330
|
op_rastreo_ori: str
|
|
331
331
|
op_monto_intereses: float
|
|
332
332
|
op_monto_ori: float
|
|
@@ -345,7 +345,7 @@ class DevolucionExtemporaneaAcreditada(Orden):
|
|
|
345
345
|
op_folio_ori: Optional[int] = None
|
|
346
346
|
paq_folio_ori: Optional[int] = None
|
|
347
347
|
|
|
348
|
-
op_fecha_oper_ori:
|
|
348
|
+
op_fecha_oper_ori: date
|
|
349
349
|
op_rastreo_ori: str
|
|
350
350
|
op_monto_ori: float
|
|
351
351
|
|
|
@@ -367,7 +367,7 @@ class DevolucionExtemporaneaEspecialAcreditada(Orden):
|
|
|
367
367
|
op_folio_ori: Optional[int] = None
|
|
368
368
|
paq_folio_ori: Optional[int] = None
|
|
369
369
|
|
|
370
|
-
op_fecha_oper_ori:
|
|
370
|
+
op_fecha_oper_ori: date
|
|
371
371
|
op_rastreo_ori: str
|
|
372
372
|
op_monto_ori: float
|
|
373
373
|
|
|
@@ -26,13 +26,20 @@ class Respuesta(BaseModel):
|
|
|
26
26
|
model_config = ConfigDict(use_enum_values=True)
|
|
27
27
|
|
|
28
28
|
def build_xml(self):
|
|
29
|
-
respuesta = etree.Element('respuesta')
|
|
30
|
-
|
|
31
|
-
for element, value in self.
|
|
32
|
-
if element in self.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
29
|
+
respuesta = etree.Element('respuesta', attrib={}, nsmap=None)
|
|
30
|
+
|
|
31
|
+
for element, value in self.model_dump(exclude={'categoria'}).items(): # noqa: E501, WPS110
|
|
32
|
+
if element not in self.model_fields:
|
|
33
|
+
continue
|
|
34
|
+
|
|
35
|
+
pascal_case_element = to_pascal_case(element)
|
|
36
|
+
subelement = etree.SubElement(
|
|
37
|
+
respuesta,
|
|
38
|
+
pascal_case_element,
|
|
39
|
+
attrib={},
|
|
40
|
+
nsmap=None,
|
|
41
|
+
)
|
|
42
|
+
subelement.text = str(value)
|
|
36
43
|
|
|
37
44
|
return respuesta
|
|
38
45
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# spei/types.py (or wherever you keep your custom types)
|
|
2
|
+
import re
|
|
3
|
+
from typing import Union
|
|
4
|
+
|
|
5
|
+
from pydantic import BeforeValidator
|
|
6
|
+
from typing_extensions import Annotated
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def validate_institution_code(value: Union[str, int]) -> int:
|
|
10
|
+
"""Validates and converts an institution code to a 3 or 5-digit integer."""
|
|
11
|
+
value_str = str(value)
|
|
12
|
+
if not re.match(r'^\d{3,5}$', value_str):
|
|
13
|
+
raise ValueError('must be exactly 3 or 5 digits')
|
|
14
|
+
|
|
15
|
+
return int(value_str)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
InstitutionCode = Annotated[int, BeforeValidator(validate_institution_code)]
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
# spei/types.py (or wherever you keep your custom types)
|
|
2
|
-
import re
|
|
3
|
-
from typing import Union
|
|
4
|
-
|
|
5
|
-
from pydantic import BeforeValidator
|
|
6
|
-
from typing_extensions import Annotated
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def validate_date_int(value: int) -> int: # noqa: WPS110
|
|
10
|
-
"""Validates and converts a date value to YYYYMMDD string format."""
|
|
11
|
-
value_str = str(value)
|
|
12
|
-
if not re.match(r'^\d{8}$', value_str):
|
|
13
|
-
raise ValueError('must be 8 digits in YYYYMMDD format')
|
|
14
|
-
|
|
15
|
-
# Additional date validation if needed
|
|
16
|
-
year = int(value_str[:4])
|
|
17
|
-
month = int(value_str[4:6])
|
|
18
|
-
day = int(value_str[6:8])
|
|
19
|
-
|
|
20
|
-
if year < 1900: # noqa: WPS432
|
|
21
|
-
raise ValueError('invalid year')
|
|
22
|
-
|
|
23
|
-
if not (1 <= month <= 12 and 1 <= day <= 31): # noqa: WPS432
|
|
24
|
-
raise ValueError('invalid date')
|
|
25
|
-
|
|
26
|
-
return int(value_str)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
DateInt = Annotated[int, BeforeValidator(validate_date_int)]
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
def validate_institution_code(value: Union[str, int]) -> int:
|
|
33
|
-
"""Validates and converts an institution code to a 3 or 5-digit integer."""
|
|
34
|
-
value_str = str(value)
|
|
35
|
-
if not re.match(r'^\d{3,5}$', value_str):
|
|
36
|
-
raise ValueError('must be exactly 3 or 5 digits')
|
|
37
|
-
|
|
38
|
-
return int(value_str)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
InstitutionCode = Annotated[int, BeforeValidator(validate_institution_code)]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|