diff --git a/extendable_fastapi/schemas.py b/extendable_fastapi/schemas.py index 6ad7a9b3..dfa7a166 100644 --- a/extendable_fastapi/schemas.py +++ b/extendable_fastapi/schemas.py @@ -6,7 +6,6 @@ class StrictExtendableBaseModel( revalidate_instances="always", validate_assignment=True, extra="forbid", - strict=True, ): """ An ExtendableBaseModel with strict validation. @@ -24,6 +23,4 @@ class StrictExtendableBaseModel( (default is "never") * validate_assignment=True: revalidate the model when the data is changed (default is False) * extra="forbid": Forbid any extra attributes (default is "ignore") - * strict=True: raise an error if a value's type does not match the field's type - annotation (default is False; Pydantic attempts to coerce values to the correct type) """ diff --git a/extendable_fastapi/tests/test_strict_extendable_base_model.py b/extendable_fastapi/tests/test_strict_extendable_base_model.py index 650982f4..f05dfd79 100644 --- a/extendable_fastapi/tests/test_strict_extendable_base_model.py +++ b/extendable_fastapi/tests/test_strict_extendable_base_model.py @@ -55,14 +55,9 @@ def test_StrictModel_extra_forbidden(self): with self.assertRaises(ValidationError): self.StrictModel(x=1, z=3, d=None) - def test_Model_strict_false(self): - # Coerce str->date is allowed - m = self.Model(x=1, d=None) + def test_StrictModel_strict_false(self): + # Coerce str->date is allowed to enable coercion from JSON + # by FastAPI + m = self.StrictModel(x=1, d=None) m.d = "2023-01-01" self.assertTrue(m.model_validate(m)) - - def test_StrictModel_strict_true(self): - # Coerce str->date is forbidden - m = self.StrictModel(x=1, d=None) - with self.assertRaises(ValidationError): - m.d = "2023-01-01"