2
0
mirror of https://github.com/frappe/books.git synced 2024-11-10 07:40:55 +00:00

fix: validateFields before insert

This commit is contained in:
Faris Ansari 2019-12-27 16:00:49 +05:30
parent e609aea4b6
commit 879b57f698

View File

@ -184,6 +184,7 @@ module.exports = class BaseDocument extends Observable {
validateInsert() {
this.validateMandatory();
this.validateFields();
}
validateMandatory() {
@ -228,6 +229,13 @@ module.exports = class BaseDocument extends Observable {
}
}
async validateFields() {
let fields = this.meta.getValidFields();
for (let field of fields) {
await this.validateField(field.fieldname, this.get(field.fieldname));
}
}
async validateField(key, value) {
let field = this.meta.getField(key);
if (!field) {