This commit is contained in:
bkfox
2022-12-12 03:09:25 +01:00
parent 180cc8bc02
commit a53a37021c
10 changed files with 62 additions and 31 deletions

View File

@ -42,7 +42,7 @@ export default class Model {
}
get errors() {
return this.data.__errors__
return this.data && this.data.__errors__
}
/**
@ -143,6 +143,13 @@ export default class Model {
return item === null ? item : new this(JSON.parse(item));
}
/**
* Return true if model instance has no data
*/
get isEmpty() {
return !this.data || Object.keys(this.data).findIndex(k => !!this.data[k] && this.data[k] !== 0) == -1
}
/**
* Return error for a specific attribute name if any
*/