fix: Add additional model validation (#3725)

This commit is contained in:
Tom Moor
2022-07-02 23:29:01 +02:00
committed by GitHub
parent 0c30d2bb34
commit 8ebe4b27b1
9 changed files with 43 additions and 5 deletions

View File

@@ -0,0 +1,16 @@
import { addAttributeOptions } from "sequelize-typescript";
/**
* A decorator that validates that a string does not include something that
* looks like a URL.
*/
export default function NotContainsUrl(target: any, propertyName: string) {
return addAttributeOptions(target, propertyName, {
validate: {
not: {
args: /(www|file:|http:|https:)+[^\s]+[\w]/,
msg: "Must not contain a URL",
},
},
});
}