fix: Add additional model validation (#3725)
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user