Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SchemaType.Number.min parameter types are incorrect #15236

Closed
2 tasks done
adf0nt3s opened this issue Feb 6, 2025 · 0 comments · Fixed by #15237
Closed
2 tasks done

SchemaType.Number.min parameter types are incorrect #15236

adf0nt3s opened this issue Feb 6, 2025 · 0 comments · Fixed by #15237
Labels
typescript Types or Types-test related issue / Pull Request
Milestone

Comments

@adf0nt3s
Copy link
Contributor

adf0nt3s commented Feb 6, 2025

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Mongoose version

8.6.4

Node.js version

22.13

MongoDB server version

6

Typescript version (if applicable)

5.7.0

Description

The parameter types for SchemaType.Number.min appear to be incorrect. Looking at the definition here, message is required. However, looking at the docs, message is optional. Looking at the few instances where I use .min in a project, I don't provide the message argument to min and the code functions as expected, so I believe the types are just incorrect here.

Steps to Reproduce

Call mySchema.path<mongoose.Schema.Types.Number>('myField').min(0), where myField is defined as a numeric field. Observe that the TS compiler complains about a missing argument:

Image

Expected Behavior

message should be an optional parameter

@vkarpov15 vkarpov15 added this to the 8.10.1 milestone Feb 6, 2025
@vkarpov15 vkarpov15 added the typescript Types or Types-test related issue / Pull Request label Feb 6, 2025
vkarpov15 added a commit that referenced this issue Feb 8, 2025
types(schema): allow calling Schema.prototype.number() with no message arg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
typescript Types or Types-test related issue / Pull Request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants