Files
unity/resources/js/user/utilities/errors.js
T
glovetleong ad85832e75 user UI setup
user login UI
2021-07-06 11:54:00 +08:00

36 lines
555 B
JavaScript
Vendored

class Errors {
constructor() {
this.errors = {};
}
has(field) {
return this.errors.hasOwnProperty(field);
}
any() {
return Object.keys(this.errors).length > 0;
}
get(field) {
if (this.errors[field]) {
return this.errors[field][0];
}
}
record(errors) {
this.errors = errors;
}
clear(field) {
if (field) {
delete this.errors[field];
return;
}
this.errors = {};
}
}
export default Errors;