@@ -72,6 +72,7 @@ def rune_serialize(
7272 self ,
7373 * ,
7474 validate_model : bool = True ,
75+ check_rune_constraints : bool = True ,
7576 strict : bool = True ,
7677 raise_validation_errors : bool = True ,
7778 indent : int | None = None ,
@@ -92,6 +93,10 @@ def rune_serialize(
9293 serialization. It checks also all Rune type constraints.
9394 Defaults to True.
9495
96+ `check_rune_constraints (bool, optional):` If `validate_model` is
97+ set to `True`, executes all model defined Rune constraints after
98+ deserialization. Defaults to True.
99+
95100 `strict (bool, optional):` Perform strict attribute validation.
96101 Defaults to True.
97102
@@ -134,8 +139,10 @@ def rune_serialize(
134139 '''
135140 try :
136141 if validate_model :
137- self .validate_model (strict = strict ,
138- raise_exc = raise_validation_errors )
142+ self .validate_model (
143+ check_rune_constraints = check_rune_constraints ,
144+ strict = strict ,
145+ raise_exc = raise_validation_errors )
139146
140147 root_meta = self .__dict__ .setdefault (ROOT_CONTAINER , {})
141148 root_meta ['@type' ] = self ._FQRTN
@@ -159,6 +166,7 @@ def rune_serialize(
159166 def rune_deserialize (cls ,
160167 rune_json : str ,
161168 validate_model : bool = True ,
169+ check_rune_constraints : bool = True ,
162170 strict : bool = True ,
163171 raise_validation_errors : bool = True ) -> BaseModel :
164172 # pylint: disable=line-too-long
@@ -171,6 +179,10 @@ def rune_deserialize(cls,
171179 deserialization. It checks also all Rune type constraints. Defaults
172180 to True.
173181
182+ `check_rune_constraints (bool, optional):` If `validate_model` is
183+ set to `True`, executes all model defined Rune constraints after
184+ deserialization. Defaults to True.
185+
174186 `strict (bool, optional):` Perform strict attribute validation.
175187 Defaults to True.
176188
@@ -186,7 +198,8 @@ def rune_deserialize(cls,
186198 rune_cls = cls ._type_to_cls (rune_dict )
187199 model = rune_cls .model_validate (rune_dict , strict = strict )
188200 if validate_model :
189- model .validate_model (strict = strict ,
201+ model .validate_model (check_rune_constraints = check_rune_constraints ,
202+ strict = strict ,
190203 raise_exc = raise_validation_errors )
191204 return model
192205
@@ -212,6 +225,7 @@ def resolve_references(self):
212225 self .bind_property_to (prop_nm , ref )
213226
214227 def validate_model (self ,
228+ check_rune_constraints = True ,
215229 recursively : bool = True ,
216230 raise_exc : bool = True ,
217231 strict : bool = True ) -> list :
@@ -226,8 +240,10 @@ def validate_model(self,
226240 self .disable_meta_checks ()
227241 att_errors = self .validate_attribs (raise_exc = raise_exc ,
228242 strict = strict )
229- return att_errors + self .validate_conditions (
230- recursively = recursively , raise_exc = raise_exc )
243+ if check_rune_constraints :
244+ att_errors .extend (self .validate_conditions (
245+ recursively = recursively , raise_exc = raise_exc ))
246+ return att_errors
231247 finally :
232248 self .enable_meta_checks ()
233249
0 commit comments