user validation stuff
This commit is contained in:
parent
1e88d63186
commit
1148eaa6a2
@ -71,7 +71,7 @@ export class BaseClass extends BaseClassWithoutId {
|
|||||||
|
|
||||||
@BeforeUpdate()
|
@BeforeUpdate()
|
||||||
@BeforeInsert()
|
@BeforeInsert()
|
||||||
do_validate() {
|
_do_validate() {
|
||||||
if (!this.id) this.id = Snowflake.generate();
|
if (!this.id) this.id = Snowflake.generate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -195,15 +195,9 @@ export class User extends BaseClass {
|
|||||||
@Column({ type: "simple-json", select: false })
|
@Column({ type: "simple-json", select: false })
|
||||||
extended_settings: string;
|
extended_settings: string;
|
||||||
|
|
||||||
// @BeforeUpdate()
|
// TODO: I don't like this method?
|
||||||
// _update_validator() { this.validate(true); }
|
validate() {
|
||||||
|
if (this.email) {
|
||||||
// @BeforeInsert()
|
|
||||||
// _insert_validator() { this.validate(false); }
|
|
||||||
|
|
||||||
validate(/*update: boolean = false*/) {
|
|
||||||
// inserting or email provided in update
|
|
||||||
if (/*!update || */this.email) {
|
|
||||||
this.email = adjustEmail(this.email);
|
this.email = adjustEmail(this.email);
|
||||||
if (!this.email)
|
if (!this.email)
|
||||||
throw FieldErrors({
|
throw FieldErrors({
|
||||||
@ -215,8 +209,7 @@ export class User extends BaseClass {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// inserting or discrim provided
|
if (this.discriminator) {
|
||||||
if (/*!update ||*/ this.discriminator) {
|
|
||||||
const discrim = Number(this.discriminator);
|
const discrim = Number(this.discriminator);
|
||||||
if (this.discriminator.length > 4)
|
if (this.discriminator.length > 4)
|
||||||
throw FieldErrors({
|
throw FieldErrors({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user