Local file storage (#5763)

Co-authored-by: Tom Moor <tom.moor@gmail.com>
This commit is contained in:
Apoorv Mishra
2023-09-21 03:42:03 +05:30
committed by GitHub
parent fea50feb0d
commit 67b1fe5514
41 changed files with 893 additions and 139 deletions

View File

@@ -0,0 +1,23 @@
import { isURL } from "class-validator";
import { addAttributeOptions } from "sequelize-typescript";
/**
* A decorator that validates that a string is a url or relative path.
*/
export default function IsUrlOrRelativePath(target: any, propertyName: string) {
return addAttributeOptions(target, propertyName, {
validate: {
validUrlOrPath(value: string) {
if (
value &&
!isURL(value, {
require_host: false,
require_protocol: false,
})
) {
throw new Error("Must be a URL or relative path");
}
},
},
});
}