marshmallow-code / marshmallow-code/marshmallow

load_only and dump_only validation

Open
#1,611 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

I was wondering if you would want some additional validation on this. I can put up a quick pull request if you like.

In schema.py, `dump_only` and `load_only` could be validated in the same way `only` and `exclude` are.

I ran into a scenario where I had something like `MySchema(partial=True,dump_only=('name'))` (note the missing comma at the end of the tuple. This passes in the string `name` and in the Marshmallow code, gets turned into a set. `set(['a', 'e', 'm', 'n'])` This happens silently. I could add the same validators that `only` and `exclude` use.

Thoughts?

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 in schema.py and compare how dump_only and load_only are handled with the existing validation for only and exclude. Reproduce the missing-comma case described in the issue, then add equivalent validation so the input is not silently treated as individual characters. Done means the invalid form is rejected consistently with only and exclude.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.