rut-validator 0.1.0__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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Eli-ezer Reuven Ramirez Ruiz
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,223 @@
1
+ Metadata-Version: 2.4
2
+ Name: rut-validator
3
+ Version: 0.1.0
4
+ Summary: Chilean RUT validation library with Pydantic, Django, and SQLAlchemy support
5
+ License: MIT
6
+ License-File: LICENSE
7
+ Keywords: rut,chile,validation,pydantic,django,sqlalchemy,fastapi
8
+ Author: Eli-ezer Reuven Ramirez Ruiz
9
+ Author-email: ramirez.ruiz.eliezer.reuven@gmail.com
10
+ Requires-Python: >=3.9,<4.0
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Classifier: Topic :: Utilities
23
+ Provides-Extra: dev
24
+ Provides-Extra: docs
25
+ Provides-Extra: fastapi
26
+ Provides-Extra: pydantic
27
+ Requires-Dist: black ; extra == "dev"
28
+ Requires-Dist: click (>=8.0.0,<9.0.0)
29
+ Requires-Dist: django (>=3.2,<5.0)
30
+ Requires-Dist: fastapi (>=0.111.0,<1.0.0) ; extra == "fastapi"
31
+ Requires-Dist: flake8 ; extra == "dev"
32
+ Requires-Dist: isort ; extra == "dev"
33
+ Requires-Dist: mypy ; extra == "dev"
34
+ Requires-Dist: myst-parser ; extra == "docs"
35
+ Requires-Dist: pre-commit ; extra == "dev"
36
+ Requires-Dist: pydantic (>=2.12.5,<3.0.0) ; extra == "pydantic"
37
+ Requires-Dist: pytest (>=7.0.0) ; extra == "dev"
38
+ Requires-Dist: pytest-cov ; extra == "dev"
39
+ Requires-Dist: ruff ; extra == "dev"
40
+ Requires-Dist: sphinx ; extra == "docs"
41
+ Requires-Dist: sphinx-rtd-theme ; extra == "docs"
42
+ Requires-Dist: sqlalchemy (>=2.0.49,<3.0.0)
43
+ Project-URL: Changelog, https://github.com/yourusername/rut-validator/blob/main/CHANGELOG.md
44
+ Project-URL: Documentation, https://rut-validator.readthedocs.io/
45
+ Project-URL: Homepage, https://github.com/yourusername/rut-validator
46
+ Project-URL: Issues, https://github.com/yourusername/rut-validator/issues
47
+ Project-URL: Repository, https://github.com/yourusername/rut-validator
48
+ Description-Content-Type: text/markdown
49
+
50
+ # rut-validator
51
+
52
+ [![PyPI version](https://badge.fury.io/py/rut-validator.svg)](https://pypi.org/project/rut-validator/)
53
+ [![Python versions](https://img.shields.io/pypi/pyversions/rut-validator.svg)](https://pypi.org/project/rut-validator/)
54
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
55
+ [![CI](https://github.com/yourusername/rut-validator/workflows/CI/badge.svg)](https://github.com/yourusername/rut-validator/actions)
56
+ [![codecov](https://codecov.io/gh/yourusername/rut-validator/branch/main/graph/badge.svg)](https://codecov.io/gh/yourusername/rut-validator)
57
+ [![Documentation Status](https://readthedocs.org/projects/rut-validator/badge/?version=latest)](https://rut-validator.readthedocs.io/en/latest/?badge=latest)
58
+
59
+ Librería para validar RUT chileno con enfoque Pydantic-first y soporte completo para frameworks web.
60
+
61
+ ## ✨ Características
62
+
63
+ - ✅ **Validación pura de RUT chileno** usando algoritmo módulo 11
64
+ - ✅ **Detección automática de formato**: dotted (`12.345.678-9`), hyphenated (`12345678-9`), numeric (`123456789`)
65
+ - ✅ **Integración completa con Pydantic** (`RutStr`)
66
+ - ✅ **Campo Django** (`RUTField`) listo para usar
67
+ - ✅ **Tipo SQLAlchemy** (`RutSQLAlchemy`) para bases de datos
68
+ - ✅ **Compatible con FastAPI** y otros frameworks web
69
+ - ✅ **Type hints completos** para mejor desarrollo
70
+ - ✅ **Sin dependencias externas** para funcionalidad core
71
+ - ✅ **Tests exhaustivos** con alta cobertura
72
+
73
+ ## 🚀 Instalación
74
+
75
+ ```bash
76
+ pip install rut-validator
77
+
78
+ # Con soporte Pydantic
79
+ pip install rut-validator[pydantic]
80
+
81
+ # Con soporte FastAPI
82
+ pip install rut-validator[fastapi]
83
+
84
+ # Para desarrollo
85
+ pip install rut-validator[dev]
86
+ ```
87
+
88
+ ## 📖 Uso Básico
89
+
90
+ ### Validación Simple
91
+
92
+ ```python
93
+ from rut_validator import RutValidator
94
+
95
+ # Validar RUT con cualquier formato
96
+ rut = RutValidator.validate("20.884.437-7")
97
+ print(f"RUT válido: {rut.formatted}") # "20.884.437-7"
98
+ print(f"Número: {rut.number}") # 20884437
99
+ print(f"Dígito: {rut.digit}") # "7"
100
+ print(f"Formato: {rut.format}") # RutFormat.DOTTED
101
+ ```
102
+
103
+ ### Detección de Formato
104
+
105
+ ```python
106
+ from rut_validator import RutValidator
107
+
108
+ # La librería detecta automáticamente el formato de entrada
109
+ formats = [
110
+ "20.884.437-7", # Formato dotted
111
+ "20884437-7", # Formato hyphenated
112
+ "208844377", # Formato numeric
113
+ ]
114
+
115
+ for rut_str in formats:
116
+ rut = RutValidator.validate(rut_str)
117
+ print(f"'{rut_str}' -> Formato: {rut.format}, Es dotted: {rut.is_dotted}")
118
+ ```
119
+
120
+ ### Con Pydantic
121
+
122
+ ```python
123
+ from pydantic import BaseModel
124
+ from rut_validator import RutStr
125
+
126
+ class User(BaseModel):
127
+ name: str
128
+ rut: RutStr # Validación automática
129
+
130
+ # Uso
131
+ user = User(name="Juan Pérez", rut="12.345.678-5")
132
+ print(user.rut) # "12.345.678-5"
133
+ ```
134
+
135
+ ### Con Django
136
+
137
+ ```python
138
+ from django.db import models
139
+ from rut_validator.core.orm.django.schema import RUTField
140
+
141
+ class Person(models.Model):
142
+ name = models.CharField(max_length=100)
143
+ rut = RUTField(unique=True) # Validación automática en DB
144
+ ```
145
+
146
+ ### Con SQLAlchemy
147
+
148
+ ```python
149
+ from sqlalchemy import Column, Integer, String
150
+ from sqlalchemy.ext.declarative import declarative_base
151
+ from rut_validator.core.orm.sqlalchemy.schema import RutSQLAlchemy
152
+
153
+ Base = declarative_base()
154
+
155
+ class Person(Base):
156
+ __tablename__ = 'persons'
157
+
158
+ id = Column(Integer, primary_key=True)
159
+ name = Column(String)
160
+ rut = Column(RutSQLAlchemy) # Validación automática
161
+ ```
162
+
163
+ ## 📚 Guía Completa
164
+
165
+ Lee la documentación completa en [docs/GUIA_RUT_VALIDATOR.md](docs/GUIA_RUT_VALIDATOR.md)
166
+
167
+ ## 🧪 Ejemplos
168
+
169
+ - [Validación pura](examples/01_pure_validation.py)
170
+ - [Uso con Pydantic](examples/02_pydantic_usage.py)
171
+ - [Uso con FastAPI](examples/03_fastapi_usage.py)
172
+
173
+ ## 🔧 Desarrollo
174
+
175
+ ### Configuración del entorno
176
+
177
+ ```bash
178
+ # Clonar repositorio
179
+ git clone https://github.com/yourusername/rut-validator.git
180
+ cd rut-validator
181
+
182
+ # Instalar dependencias de desarrollo
183
+ poetry install --with dev
184
+
185
+ # Ejecutar tests
186
+ poetry run pytest
187
+
188
+ # Ejecutar linting
189
+ poetry run black src/ tests/
190
+ poetry run isort src/ tests/
191
+ poetry run flake8 src/ tests/
192
+ poetry run mypy src/rut_validator/
193
+ ```
194
+
195
+ ### Pre-commit hooks
196
+
197
+ ```bash
198
+ poetry run pre-commit install
199
+ ```
200
+
201
+ ## 🤝 Contribuir
202
+
203
+ 1. Fork el proyecto
204
+ 2. Crea una rama para tu feature (`git checkout -b feature/AmazingFeature`)
205
+ 3. Commit tus cambios (`git commit -m 'Add some AmazingFeature'`)
206
+ 4. Push a la rama (`git push origin feature/AmazingFeature`)
207
+ 5. Abre un Pull Request
208
+
209
+ ## 📄 Licencia
210
+
211
+ Este proyecto está bajo la Licencia MIT - ver el archivo [LICENSE](LICENSE) para más detalles.
212
+
213
+ ## 🙏 Agradecimientos
214
+
215
+ - Algoritmo de validación basado en el estándar chileno del Servicio de Impuestos Internos
216
+ - Inspirado en bibliotecas similares pero con enfoque moderno y tipado fuerte
217
+
218
+ ## 📞 Soporte
219
+
220
+ - 🐛 [Reportar bugs](https://github.com/yourusername/rut-validator/issues)
221
+ - 💡 [Sugerir features](https://github.com/yourusername/rut-validator/issues)
222
+ - 📖 [Documentación](https://rut-validator.readthedocs.io/)
223
+
@@ -0,0 +1,173 @@
1
+ # rut-validator
2
+
3
+ [![PyPI version](https://badge.fury.io/py/rut-validator.svg)](https://pypi.org/project/rut-validator/)
4
+ [![Python versions](https://img.shields.io/pypi/pyversions/rut-validator.svg)](https://pypi.org/project/rut-validator/)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+ [![CI](https://github.com/yourusername/rut-validator/workflows/CI/badge.svg)](https://github.com/yourusername/rut-validator/actions)
7
+ [![codecov](https://codecov.io/gh/yourusername/rut-validator/branch/main/graph/badge.svg)](https://codecov.io/gh/yourusername/rut-validator)
8
+ [![Documentation Status](https://readthedocs.org/projects/rut-validator/badge/?version=latest)](https://rut-validator.readthedocs.io/en/latest/?badge=latest)
9
+
10
+ Librería para validar RUT chileno con enfoque Pydantic-first y soporte completo para frameworks web.
11
+
12
+ ## ✨ Características
13
+
14
+ - ✅ **Validación pura de RUT chileno** usando algoritmo módulo 11
15
+ - ✅ **Detección automática de formato**: dotted (`12.345.678-9`), hyphenated (`12345678-9`), numeric (`123456789`)
16
+ - ✅ **Integración completa con Pydantic** (`RutStr`)
17
+ - ✅ **Campo Django** (`RUTField`) listo para usar
18
+ - ✅ **Tipo SQLAlchemy** (`RutSQLAlchemy`) para bases de datos
19
+ - ✅ **Compatible con FastAPI** y otros frameworks web
20
+ - ✅ **Type hints completos** para mejor desarrollo
21
+ - ✅ **Sin dependencias externas** para funcionalidad core
22
+ - ✅ **Tests exhaustivos** con alta cobertura
23
+
24
+ ## 🚀 Instalación
25
+
26
+ ```bash
27
+ pip install rut-validator
28
+
29
+ # Con soporte Pydantic
30
+ pip install rut-validator[pydantic]
31
+
32
+ # Con soporte FastAPI
33
+ pip install rut-validator[fastapi]
34
+
35
+ # Para desarrollo
36
+ pip install rut-validator[dev]
37
+ ```
38
+
39
+ ## 📖 Uso Básico
40
+
41
+ ### Validación Simple
42
+
43
+ ```python
44
+ from rut_validator import RutValidator
45
+
46
+ # Validar RUT con cualquier formato
47
+ rut = RutValidator.validate("20.884.437-7")
48
+ print(f"RUT válido: {rut.formatted}") # "20.884.437-7"
49
+ print(f"Número: {rut.number}") # 20884437
50
+ print(f"Dígito: {rut.digit}") # "7"
51
+ print(f"Formato: {rut.format}") # RutFormat.DOTTED
52
+ ```
53
+
54
+ ### Detección de Formato
55
+
56
+ ```python
57
+ from rut_validator import RutValidator
58
+
59
+ # La librería detecta automáticamente el formato de entrada
60
+ formats = [
61
+ "20.884.437-7", # Formato dotted
62
+ "20884437-7", # Formato hyphenated
63
+ "208844377", # Formato numeric
64
+ ]
65
+
66
+ for rut_str in formats:
67
+ rut = RutValidator.validate(rut_str)
68
+ print(f"'{rut_str}' -> Formato: {rut.format}, Es dotted: {rut.is_dotted}")
69
+ ```
70
+
71
+ ### Con Pydantic
72
+
73
+ ```python
74
+ from pydantic import BaseModel
75
+ from rut_validator import RutStr
76
+
77
+ class User(BaseModel):
78
+ name: str
79
+ rut: RutStr # Validación automática
80
+
81
+ # Uso
82
+ user = User(name="Juan Pérez", rut="12.345.678-5")
83
+ print(user.rut) # "12.345.678-5"
84
+ ```
85
+
86
+ ### Con Django
87
+
88
+ ```python
89
+ from django.db import models
90
+ from rut_validator.core.orm.django.schema import RUTField
91
+
92
+ class Person(models.Model):
93
+ name = models.CharField(max_length=100)
94
+ rut = RUTField(unique=True) # Validación automática en DB
95
+ ```
96
+
97
+ ### Con SQLAlchemy
98
+
99
+ ```python
100
+ from sqlalchemy import Column, Integer, String
101
+ from sqlalchemy.ext.declarative import declarative_base
102
+ from rut_validator.core.orm.sqlalchemy.schema import RutSQLAlchemy
103
+
104
+ Base = declarative_base()
105
+
106
+ class Person(Base):
107
+ __tablename__ = 'persons'
108
+
109
+ id = Column(Integer, primary_key=True)
110
+ name = Column(String)
111
+ rut = Column(RutSQLAlchemy) # Validación automática
112
+ ```
113
+
114
+ ## 📚 Guía Completa
115
+
116
+ Lee la documentación completa en [docs/GUIA_RUT_VALIDATOR.md](docs/GUIA_RUT_VALIDATOR.md)
117
+
118
+ ## 🧪 Ejemplos
119
+
120
+ - [Validación pura](examples/01_pure_validation.py)
121
+ - [Uso con Pydantic](examples/02_pydantic_usage.py)
122
+ - [Uso con FastAPI](examples/03_fastapi_usage.py)
123
+
124
+ ## 🔧 Desarrollo
125
+
126
+ ### Configuración del entorno
127
+
128
+ ```bash
129
+ # Clonar repositorio
130
+ git clone https://github.com/yourusername/rut-validator.git
131
+ cd rut-validator
132
+
133
+ # Instalar dependencias de desarrollo
134
+ poetry install --with dev
135
+
136
+ # Ejecutar tests
137
+ poetry run pytest
138
+
139
+ # Ejecutar linting
140
+ poetry run black src/ tests/
141
+ poetry run isort src/ tests/
142
+ poetry run flake8 src/ tests/
143
+ poetry run mypy src/rut_validator/
144
+ ```
145
+
146
+ ### Pre-commit hooks
147
+
148
+ ```bash
149
+ poetry run pre-commit install
150
+ ```
151
+
152
+ ## 🤝 Contribuir
153
+
154
+ 1. Fork el proyecto
155
+ 2. Crea una rama para tu feature (`git checkout -b feature/AmazingFeature`)
156
+ 3. Commit tus cambios (`git commit -m 'Add some AmazingFeature'`)
157
+ 4. Push a la rama (`git push origin feature/AmazingFeature`)
158
+ 5. Abre un Pull Request
159
+
160
+ ## 📄 Licencia
161
+
162
+ Este proyecto está bajo la Licencia MIT - ver el archivo [LICENSE](LICENSE) para más detalles.
163
+
164
+ ## 🙏 Agradecimientos
165
+
166
+ - Algoritmo de validación basado en el estándar chileno del Servicio de Impuestos Internos
167
+ - Inspirado en bibliotecas similares pero con enfoque moderno y tipado fuerte
168
+
169
+ ## 📞 Soporte
170
+
171
+ - 🐛 [Reportar bugs](https://github.com/yourusername/rut-validator/issues)
172
+ - 💡 [Sugerir features](https://github.com/yourusername/rut-validator/issues)
173
+ - 📖 [Documentación](https://rut-validator.readthedocs.io/)
@@ -0,0 +1,143 @@
1
+ [project]
2
+ name = "rut-validator"
3
+ version = "0.1.0"
4
+ description = "Chilean RUT validation library with Pydantic, Django, and SQLAlchemy support"
5
+ authors = [
6
+ {name = "Eli-ezer Reuven Ramirez Ruiz", email = "ramirez.ruiz.eliezer.reuven@gmail.com"}
7
+ ]
8
+ readme = "README.md"
9
+ license = {text = "MIT"}
10
+ requires-python = ">=3.9,<4.0"
11
+ keywords = ["rut", "chile", "validation", "pydantic", "django", "sqlalchemy", "fastapi"]
12
+ classifiers = [
13
+ "Development Status :: 4 - Beta",
14
+ "Intended Audience :: Developers",
15
+ "License :: OSI Approved :: MIT License",
16
+ "Operating System :: OS Independent",
17
+ "Programming Language :: Python :: 3",
18
+ "Programming Language :: Python :: 3.9",
19
+ "Programming Language :: Python :: 3.10",
20
+ "Programming Language :: Python :: 3.11",
21
+ "Programming Language :: Python :: 3.12",
22
+ "Programming Language :: Python :: 3.13",
23
+ "Topic :: Software Development :: Libraries :: Python Modules",
24
+ "Topic :: Utilities",
25
+ ]
26
+ dependencies = [
27
+ "sqlalchemy (>=2.0.49,<3.0.0)",
28
+ "django (>=3.2,<5.0)",
29
+ "click (>=8.0.0,<9.0.0)"
30
+ ]
31
+
32
+ [project.optional-dependencies]
33
+ pydantic = ["pydantic (>=2.12.5,<3.0.0)"]
34
+ fastapi = ["fastapi (>=0.111.0,<1.0.0)"]
35
+ dev = [
36
+ "pytest (>=7.0.0)",
37
+ "pytest-cov",
38
+ "black",
39
+ "isort",
40
+ "flake8",
41
+ "ruff",
42
+ "mypy",
43
+ "pre-commit"
44
+ ]
45
+ docs = [
46
+ "sphinx",
47
+ "sphinx-rtd-theme",
48
+ "myst-parser"
49
+ ]
50
+
51
+ [project.scripts]
52
+ rut-validator = "rut_validator.cli:cli"
53
+
54
+ [project.urls]
55
+ Homepage = "https://github.com/yourusername/rut-validator"
56
+ Documentation = "https://rut-validator.readthedocs.io/"
57
+ Repository = "https://github.com/yourusername/rut-validator"
58
+ Issues = "https://github.com/yourusername/rut-validator/issues"
59
+ Changelog = "https://github.com/yourusername/rut-validator/blob/main/CHANGELOG.md"
60
+
61
+ [tool.poetry]
62
+ packages = [{include = "rut_validator", from = "src"}]
63
+
64
+ [tool.black]
65
+ line-length = 88
66
+ target-version = ['py39', 'py310', 'py311', 'py312', 'py313']
67
+ include = '\.pyi?$'
68
+ extend-exclude = '''
69
+ /(
70
+ # directories
71
+ \.eggs
72
+ | \.git
73
+ | \.hg
74
+ | \.mypy_cache
75
+ | \.tox
76
+ | \.venv
77
+ | build
78
+ | dist
79
+ )/
80
+ '''
81
+
82
+ [tool.isort]
83
+ profile = "black"
84
+ multi_line_output = 3
85
+ line_length = 88
86
+ known_first_party = ["rut_validator"]
87
+
88
+ [tool.mypy]
89
+ python_version = "3.10"
90
+ warn_return_any = true
91
+ warn_unused_configs = true
92
+ disallow_untyped_defs = true
93
+ disallow_incomplete_defs = true
94
+ check_untyped_defs = true
95
+ disallow_untyped_decorators = true
96
+ no_implicit_optional = true
97
+ warn_redundant_casts = true
98
+ warn_unused_ignores = true
99
+ warn_no_return = true
100
+ warn_unreachable = true
101
+ strict_equality = true
102
+
103
+ [[tool.mypy.overrides]]
104
+ module = [
105
+ "pydantic.*",
106
+ "django.*",
107
+ "sqlalchemy.*",
108
+ "fastapi.*"
109
+ ]
110
+ ignore_missing_imports = true
111
+
112
+ [tool.pytest.ini_options]
113
+ minversion = "7.0"
114
+ addopts = "-ra -q --strict-markers --strict-config"
115
+ testpaths = ["tests"]
116
+ python_files = "test_*.py"
117
+ python_classes = "Test*"
118
+ python_functions = "test_*"
119
+ filterwarnings = [
120
+ "error",
121
+ "ignore::UserWarning",
122
+ "ignore::DeprecationWarning"
123
+ ]
124
+
125
+ [tool.coverage.run]
126
+ source = ["src/rut_validator"]
127
+ omit = [
128
+ "*/tests/*",
129
+ "*/test_*.py",
130
+ "setup.py"
131
+ ]
132
+
133
+ [tool.coverage.report]
134
+ exclude_lines = [
135
+ "pragma: no cover",
136
+ "def __repr__",
137
+ "raise AssertionError",
138
+ "raise NotImplementedError"
139
+ ]
140
+
141
+ [build-system]
142
+ requires = ["poetry-core>=2.0.0,<3.0.0"]
143
+ build-backend = "poetry.core.masonry.api"
@@ -0,0 +1,26 @@
1
+ """
2
+ rut-validator: Validation of Chilean RUTs for Pydantic and FastAPI
3
+ """
4
+
5
+ from .core.validator import RutValidator
6
+ from .core.patterns import RutFormat
7
+ from .core.orm.pydantic.schema import RutStr
8
+ from .errors import (
9
+ RutInvalidFormatError,
10
+ RutInvalidValueError,
11
+ RutModuleElevenValidationError,
12
+ RutValidationError,
13
+ )
14
+ from .types.rut import Rut as ValidatedRut
15
+
16
+ __version__ = "0.1.0"
17
+ __all__ = [
18
+ "RutValidator", # For pure validation
19
+ "ValidatedRut", # Validation result (alias for Rut)
20
+ "RutStr", # For use with Pydantic
21
+ "RutFormat", # Format enumeration
22
+ "RutInvalidFormatError", # Custom exception
23
+ "RutInvalidValueError", # Custom exception
24
+ "RutModuleElevenValidationError", # Custom exception
25
+ "RutValidationError", # Base exception
26
+ ]
@@ -0,0 +1,3 @@
1
+ """Constants for RUT validation."""
2
+
3
+ RUT_MODULE_ELEVEN_FACTORS = [2, 3, 4, 5, 6, 7]
@@ -0,0 +1,14 @@
1
+ """Core validation logic - no external dependencies"""
2
+
3
+ from .formatter import RutFormatter
4
+ from .parser import RutParser
5
+ from .patterns import RutPatterns, RutFormat
6
+ from .validator import RutValidator
7
+
8
+ __all__ = [
9
+ "RutFormatter",
10
+ "RutParser",
11
+ "RutPatterns",
12
+ "RutFormat",
13
+ "RutValidator",
14
+ ]
@@ -0,0 +1,32 @@
1
+ from rut_validator.core.patterns import RutPatterns
2
+
3
+
4
+ class RutFormatter:
5
+ """Formatter for RUT strings with different output formats."""
6
+
7
+ @staticmethod
8
+ def to_original_format(rut: str) -> str:
9
+ """
10
+ Converts a RUT string to its original format with dots and dashes (e.g. "12345678-9" -> "12.345.678-9").
11
+
12
+ Args:
13
+ rut (str): The RUT string to format (e.g. "123456789")
14
+
15
+ Returns:
16
+ str: The RUT string in original format (e.g. "12.345.678-9")
17
+ """
18
+ return RutPatterns.formatted(rut)
19
+
20
+ @staticmethod
21
+ def to_normalize_format(rut: str) -> str:
22
+ """
23
+ Cleans the RUT string by removing dots and dashes, leaving only the digits and check digit.
24
+ This is used internally to normalize the RUT before validation.
25
+
26
+ Args:
27
+ rut (str): The RUT string to clean (e.g. "12.345.678-9")
28
+
29
+ Returns:
30
+ str: The cleaned RUT string (e.g. "123456789")
31
+ """
32
+ return RutPatterns.normalized(rut)