JS library/modules for Input validation and output encoding

Hey,

as requested inside the Shared resonsibility model it necessary for security reasons to do “Input validation and output encoding”.

Which libraries/modules do you suggest for this purpose? Or are you doing it all by your own?
Are the different for Custom UI / Forge UI Kit?