From 907af6a4dc781cefa6855f1e070850bcf6394dc7 Mon Sep 17 00:00:00 2001 From: Jose Tomas Robles Hahn Date: Tue, 9 Sep 2025 19:56:20 -0300 Subject: [PATCH] chore(extras): Refactor `dj_form_fields.RutField.to_python()` Validate "digito verificador" of RUT using `Rut.validate_dv()` instead of `Rut.calc_dv()`. --- src/cl_sii/extras/dj_form_fields.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cl_sii/extras/dj_form_fields.py b/src/cl_sii/extras/dj_form_fields.py index 829f7e5b..fdf39c9d 100644 --- a/src/cl_sii/extras/dj_form_fields.py +++ b/src/cl_sii/extras/dj_form_fields.py @@ -66,7 +66,7 @@ def to_python(self, value: Optional[object]) -> Optional[Rut]: if ( converted_value is not None and self.validate_dv - and Rut.calc_dv(converted_value.digits) != converted_value.dv + and not converted_value.validate_dv(raise_exception=False) ): raise django.core.exceptions.ValidationError( self.error_messages['invalid_dv'],