Skip to content

Commit

Permalink
DateTime field: reject timestamp True/False
Browse files Browse the repository at this point in the history
  • Loading branch information
lafrech committed Apr 30, 2024
1 parent 845f573 commit 6e72beb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/marshmallow/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -1285,6 +1285,8 @@ def _serialize(self, value, attr, obj, **kwargs) -> str | float | None:
return value.strftime(data_format)

def _deserialize(self, value, attr, data, **kwargs) -> dt.datetime:
if value is True or value is False:
raise self.make_error("invalid", input=value, obj_type=self.OBJ_TYPE)
data_format = self.format or self.DEFAULT_FORMAT
func = self.DESERIALIZATION_FUNCS.get(data_format)
try:
Expand Down
2 changes: 2 additions & 0 deletions tests/test_deserialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,8 @@ def test_field_toggle_show_invalid_value_in_error_message(self):
[
"not-a-datetime",
42,
True,
False,
0,
"",
[],
Expand Down

0 comments on commit 6e72beb

Please sign in to comment.