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

Missing reason in the ValidatorProps type #14496

Closed
2 tasks done
lafeuil opened this issue Apr 3, 2024 · 0 comments · Fixed by #14499
Closed
2 tasks done

Missing reason in the ValidatorProps type #14496

lafeuil opened this issue Apr 3, 2024 · 0 comments · Fixed by #14499

Comments

@lafeuil
Copy link

lafeuil commented Apr 3, 2024

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.2.4

Node.js version

20

MongoDB server version

6

Typescript version (if applicable)

5.4.3

Description

The reason field is missing in the ValidatorProps type. This interface is used to define the argument of the message function when declaring a validator.

Steps to Reproduce

Use the example in the SchemaType.prototype.validate() API doc

schema.path('name').validate({
  validator: () => throw new Error('Oops!'),
  // `errors['name']` will be "Oops!"
  message: (props) => props.reason.message,
});`

Expected Behavior

The ValidatorProps interface could be :

interface ValidatorProps {
  path: string;
  fullPath: string;
  value: any;
  reason: Error;
}
vkarpov15 added a commit that referenced this issue Apr 4, 2024
… and add support for accessing validator `reason`

Fix #14496
vkarpov15 added a commit that referenced this issue Apr 7, 2024
types(validation): support function for validator `message` property,  and add support for accessing validator `reason`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant