mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
19 lines
459 B
TypeScript
19 lines
459 B
TypeScript
import { registerDecorator } from 'class-validator';
|
|
|
|
export function NoXss() {
|
|
return (object: object, propertyName: string): void => {
|
|
registerDecorator({
|
|
name: 'NoXss',
|
|
target: object.constructor,
|
|
propertyName,
|
|
constraints: [propertyName],
|
|
options: { message: `Malicious ${propertyName}` },
|
|
validator: {
|
|
validate(value: string) {
|
|
return !/(^http|^www)|<(\s*)?(script|a)|(\.[\p{L}\d-]+)/u.test(value);
|
|
},
|
|
},
|
|
});
|
|
};
|
|
}
|