MongoEngine / MongoEngine/mongoengine

Validation of choices in a field

Open
#1,395 5 comments 2 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

In current workflow mongoengine always checks for choices, regardless of the value being empty.
Django does not check choices if value is empty and it's always been like that.

Basically, if value is being check for availability against choices, it has passed the not empty if required validation.

I believe that the behaviour should be equal to django's.

I'll be able to provide PR with this changes, just want to figure out if this behaviour might have been intentional for some reason.

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 mongoengine/base/fields.py at the choices-checking code linked in the issue, then compare it with Django's linked field implementation. Confirm how empty values are handled relative to required validation. Done means the behavior for empty values matches the intended Django behavior, with the existing required-value behavior preserved.

Written by the indexing model from the issue text.

Assessment

Tech stack
mongodb, python
Domain
backend, databases
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.