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

@@ -38,6 +38,8 @@ import Encrypted, {
getEncryptedColumn,
} from "./decorators/Encrypted";
import Fix from "./decorators/Fix";
import Length from "./validators/Length";
import NotContainsUrl from "./validators/NotContainsUrl";
/**
* Flags that are available for setting on the user.
@@ -86,12 +88,17 @@ export enum UserFlag {
@Fix
class User extends ParanoidModel {
@IsEmail
@Length({ min: 0, max: 255, msg: "Must be less than 255 characters" })
@Column
email: string | null;
@NotContainsUrl
@Length({ min: 0, max: 255, msg: "Must be less than 255 characters" })
@Column
username: string | null;
@NotContainsUrl
@Length({ min: 0, max: 255, msg: "Must be less than 255 characters" })
@Column
name: string;
@@ -141,6 +148,7 @@ class User extends ParanoidModel {
@Column
language: string;
@Length({ min: 0, max: 255, msg: "Must be less than 255 characters" })
@Column(DataType.STRING)
get avatarUrl() {
const original = this.getDataValue("avatarUrl");