Update validate data
This commit is contained in:
@@ -339,85 +339,56 @@ export default {
|
||||
// Xóa lỗi cũ
|
||||
this.errors = this.errors.filter((err) => err.name !== 'fullname');
|
||||
|
||||
if (this.$empty(fullName)) {
|
||||
const res = this.$validateFullName(fullName);
|
||||
|
||||
if (!res.status) {
|
||||
this.errors.push({
|
||||
name: 'fullname',
|
||||
text: 'Họ và tên không được để trống.',
|
||||
text: res.message,
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fullName.length < 5) {
|
||||
this.errors.push({
|
||||
name: 'fullname',
|
||||
text: 'Họ và tên quá ngắn. Yêu cầu từ 5 kí tự trở nên.',
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
validateEmail(email) {
|
||||
// Xóa lỗi cũ
|
||||
this.errors = this.errors.filter((err) => err.name !== 'email');
|
||||
|
||||
if (this.$empty(email)) {
|
||||
const res = this.$validateEmail(email);
|
||||
|
||||
if (!res.status) {
|
||||
this.errors.push({
|
||||
name: 'email',
|
||||
text: 'Email không được để trống.',
|
||||
text: res.message,
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!this.$regexEmail(String(email).toLowerCase())) {
|
||||
this.errors.push({
|
||||
name: 'email',
|
||||
text: 'Email không đúng định dạng.',
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
validatePassword(password) {
|
||||
// Xóa lỗi cũ
|
||||
this.errors = this.errors.filter((err) => err.name !== 'password');
|
||||
|
||||
if (this.$empty(password)) {
|
||||
const res = this.$validatePassword(password);
|
||||
|
||||
if (!res.status) {
|
||||
this.errors.push({
|
||||
name: 'password',
|
||||
text: 'Mật khẩu không được để trống.',
|
||||
text: res.message,
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!this.$regexPassword(String(password).toLowerCase())) {
|
||||
this.errors.push({
|
||||
name: 'password',
|
||||
text: 'Mật khẩu không đúng định dạng.',
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
validatePhone(phone) {
|
||||
// Xóa lỗi cũ
|
||||
this.errors = this.errors.filter((err) => err.name !== 'phone');
|
||||
if (!this.$empty(phone)) {
|
||||
if (!this.$regexPhone(phone)) {
|
||||
this.errors.push({
|
||||
name: 'phone',
|
||||
text: 'Số điện thoại không hợp lệ.',
|
||||
});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
const res = this.$validatePhone(phone, true);
|
||||
|
||||
if (!res.status) {
|
||||
this.errors.push({
|
||||
name: 'phone',
|
||||
text: res.message,
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
async createAccount() {
|
||||
@@ -497,8 +468,6 @@ export default {
|
||||
},
|
||||
onSuccess(googleUser) {
|
||||
let info = googleUser.getBasicProfile();
|
||||
console.log('Google info', info);
|
||||
|
||||
let keys = Object.keys(info);
|
||||
this.email = info[keys[5]];
|
||||
this.fullname = info[keys[1]];
|
||||
|
||||
Reference in New Issue
Block a user