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
I want run body().escape() on it all but when I do I get custom as '[object Object]'.
The thing to note here is I will not know what keys are inside custom and also I will not know what keys are inside user_info. The fields that come through are completely unknown. So I have tried [body('user_info.custom.*').escape(), body('user_info.*).escape()] but this still return custom as [object Object]. I really just want to escape every key that comes through. But is this possible when I dont know the key names and it is nested like this?
The text was updated successfully, but these errors were encountered:
You can go through every key of user_info(one level of nested) like this
body("user_info.*").customSanitizer((value)=>{// if you really know that your values are objects{} and stringsconstisObject=typeofvalue==="object";if(isObject)returnvalue;returnmyEscapeFunction(value);}),
But there's also a problem that you need to have your own escape function.
Say I have a req.body like so
{ user_info: { custom: { '63': 'aaaaaaaa' }, email: 'test@test.com', name: 'A Name', } }
I want run body().escape() on it all but when I do I get
custom
as '[object Object]'.The thing to note here is I will not know what keys are inside custom and also I will not know what keys are inside user_info. The fields that come through are completely unknown. So I have tried
[body('user_info.custom.*').escape(), body('user_info.*).escape()]
but this still return custom as [object Object]. I really just want to escape every key that comes through. But is this possible when I dont know the key names and it is nested like this?The text was updated successfully, but these errors were encountered: