You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The client-redirects plugin uses Yup to validate user inputs.
In case user options do not match what's expected by the plugin (and the TypeScript types), it fails fast with an actionable error message.
@lex111 mentioned here that this is not really consistent with the behavior of the other plugins that do not really validate the user options, and maybe we should revisit the development process of plugins to follow what has been done in the client redirects plugin.
I discussed this with @yangshun, and he liked the idea to validate user inputs early with Yup.
He proposed a validateOptions() plugin lifecycle, where the user could just provide a Yup schema.
We also need to think about "option normalization", ie the process of transforming partial user-provided options into a convenient option type (ie, often adding default values to "complete" the user object)
What do you think of this idea of generalizing user input validation everywhere?
The text was updated successfully, but these errors were encountered:
For example, during a v1->v2 migration, I got bitten by migrating incorrectly the headerLinks to the new format. The site did work but the links didn't appear anywhere because i forgot to add position left/right. That could be prevented with validation.
💥 Proposal
The client-redirects plugin uses Yup to validate user inputs.
In case user options do not match what's expected by the plugin (and the TypeScript types), it fails fast with an actionable error message.
@lex111 mentioned here that this is not really consistent with the behavior of the other plugins that do not really validate the user options, and maybe we should revisit the development process of plugins to follow what has been done in the client redirects plugin.
I discussed this with @yangshun, and he liked the idea to validate user inputs early with Yup.
He proposed a
validateOptions()
plugin lifecycle, where the user could just provide a Yup schema.We also need to think about "option normalization", ie the process of transforming partial user-provided options into a convenient option type (ie, often adding default values to "complete" the user object)
What do you think of this idea of generalizing user input validation everywhere?
The text was updated successfully, but these errors were encountered: