mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/unity.git
synced 2026-08-19 12:24:01 +00:00
ad85832e75
user login UI
36 lines
555 B
JavaScript
Vendored
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;
|