Sanitizing blanks
Is there a way in joi to change '' or ' ' to null for all optional parameters that are strings?
Right now I have to pass a .allow('') when a parameter is because joi by default does not accept '' and then i have to check each parameter to see if its blank and rename to null.
Can a setting be added to sanitize all empty string and string with spaces to null and an option to allow empty strings?
.allow('') is going to be the setting to allow an empty string. If you want to allow a string which just contains spaces and other whitespace characters, you could use Joi.string().trim().allow(''), but that appears to be failing with the error value must be a string
As far as renaming the param to null, this sounds very specific to your application.
I have to disagree here. Typically, forms do not allow users to submit null instead of a blank. And many developers, including myself, like to normalize blanks as null values before persisting them. Every project I've worked on, not just a "specific application".
This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.