marshmallow-code / marshmallow-code/marshmallow

Integer field won't accept boolean value when strict is False

Open
#1,475 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
7.2k
Forks
738
Avg merge
1d 23h
Merged PRs (30d)
7

Description

As mentioned in the documentation, for `Integer` fields when the strict parameter is False any value that is castable to integer is acceptable:
> strict – If True, only integer types are valid. Otherwise, any value castable to int is valid.

But actually, if you pass True or False when strict is False the validation will fail although boolean values are castable to int:
```
assert int(True) == 1
assert int(False) == 0
```

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the Integer field's validation and strict=False handling in the marshmallow codebase. Reproduce the issue with True and False, then verify that boolean values follow the documented castable-to-integer behavior without changing strict=True validation.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.