Jelajahi Sumber

+validate method in Savable

Ivan Asmer 3 tahun lalu
induk
melakukan
13ad1f5e6c
1 mengubah file dengan 2 tambahan dan 2 penghapusan
  1. 2 2
      index.js

+ 2 - 2
index.js

@@ -99,8 +99,8 @@ const mm = db => {
         }
 
         async save(noSync=false){
-            if (this.validate && !this.validate()){
-                throw new SyntaxError(`validation error entity ${this._id} of class ${this.constructor.name} (${this.name || this.key})`)
+            if (this.validate && !(await this.validate())){
+                throw new SyntaxError(`validation error on entity ${this._id} of class ${this.constructor.name} (${this.name || this.key}) save`)
             }
             if (this.empty) return this;