Automattic / Automattic/mongoose

{ enum: true } option for queries or perhaps Model.validate

Open
#15,581 1 comment 0 reactions 0 assignees View on GitHub
enhancement new feature
Dominant language
JavaScript
Stars
27.5k
Forks
4k
Avg merge
2d 7h
Merged PRs (30d)
35

Description

### Prerequisites

- [x] I have written a descriptive issue title
- [x] I have searched existing issues to ensure the feature has not already been requested

### 🚀 Feature Proposal

Currently, when you query for values not included in an enum, no warnings or errors are thrown. We have `strictQuery` which checks the keys, but we don't have something similar for values.

### Motivation

Sometimes when working on multiple project with similar designs, names can be confused i.e. `done` versus `completed` or `in_progress` vs `in-progress`

### Example

`TestModel.find(filter, { enum: true });`

Contributor guide

Open the contributing guide

Research direction

Start by reading the existing strictQuery behavior and enum validation paths referenced in the proposal, then compare the suggested TestModel.find(filter, { enum: true }) usage with the Model.validate alternative. Done requires a settled scope and design for detecting values outside an enum, including whether queries, validation, or both should report them.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, mongodb
Domain
database
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.