summary refs log tree commit diff
path: root/util/src
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-08-26 02:07:16 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-08-26 02:07:16 +0200
commitc4426920a113b419c22f27eda347e5a04c108acc (patch)
treee475e8af64c3e6c7e6086c1cc09c3a8daa9046a0 /util/src
parent:sparkles: unit test (diff)
downloadserver-c4426920a113b419c22f27eda347e5a04c108acc.tar.xz
:bug: fix unit tests
Diffstat (limited to 'util/src')
-rw-r--r--util/src/entities/BaseClass.ts6
1 files changed, 4 insertions, 2 deletions
diff --git a/util/src/entities/BaseClass.ts b/util/src/entities/BaseClass.ts

index 22d9f6d6..2d2457de 100644 --- a/util/src/entities/BaseClass.ts +++ b/util/src/entities/BaseClass.ts
@@ -23,7 +23,9 @@ export class BaseClass extends BaseEntity { super(); this.assign(props); - if (!this.construct.schema) this.construct.schema = { ...schema, $ref: `#/definitions/${this.construct.name}` }; + if (!this.construct.schema) { + this.construct.schema = ajv.compile({ ...schema, $ref: `#/definitions/${this.construct.name}` }); + } this.id = this.opts.id || Snowflake.generate(); } @@ -51,7 +53,7 @@ export class BaseClass extends BaseEntity { @BeforeUpdate() @BeforeInsert() validate() { - const valid = ajv.validate(this.construct.schema, this.toJSON()); + const valid = this.construct.schema(this.toJSON()); if (!valid) throw ajv.errors; return this; }