-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Feature Request: Context Data for custom validations #1696
Comments
I know this is currently closed but I would also love some way to pass context information to custom validators. For example, I want to validate duplicates but exclude the current object id (currently I have to add Right now it seems like the only way is to add them to the actual schema, pass the data in and then remove it again from the schema before processing the safeParsed data (defeating slightly the idea behind safe parse in my opinion) |
The lack of this feature was a deal breaker for my use case - had to replace it with yup, which offers this function, and refactor. |
It would be great if custom validations with refine or superRefine could access data that is given as a parameter to parse, parseAsync, safeParse or safeParseAsync.
Joi for example allows to give a context object as a second parameter to its validate function which then can be evaluated in custom rules.
The text was updated successfully, but these errors were encountered: