MongoEngine / MongoEngine/mongoengine

Clean validation problem

Open
#1,985 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
4.3k
Forks
1.2k
Avg merge
4h 41m
Merged PRs (30d)
11

Description

Hi,
I have noticed that clean method that should be override in order to allow custom validation on save() isn't called before the basic validations.

Suppose we have a required field that we want to perform a custom validation on it, an expected behavior would be that the clean method will be called after the validation of the required field. The reality is that the clean method called before the basic validation - so in order to add a custom validation we have to check if the required field isn't None and so as the rest of the basic validation.

PR for that?

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 tracing save() validation and the clean method described in the issue, focusing on the order of custom validation versus required-field checks. Reproduce the case with a required field and custom validation, then verify that clean runs after the basic validations and that the resulting validation behavior matches the expected ordering.

Written by the indexing model from the issue text.

Assessment

Tech stack
mongodb, python
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.