'use strict';
|
|
class Validator {
|
constructor(arg) {
|
|
}
|
|
checkEmpty(val) {
|
if (typeof val === 'boolean') {
|
return false
|
}
|
if (typeof val === 'number') {
|
return false
|
}
|
if (val instanceof Array) {
|
if (val.length === 0) return true
|
} else if (val instanceof Object) {
|
if (JSON.stringify(val) === '{}') return true
|
} else {
|
if (val === 'null' || val == null || val === 'undefined' || val === undefined || val === '') return true
|
return false
|
}
|
return false
|
}
|
|
checkEmail(email) {
|
return RegExp(
|
/^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/)
|
.test(
|
email);
|
}
|
|
checkMobile(mobile) {
|
return RegExp(/^1[34578]\d{9}$/).test(mobile);
|
}
|
|
checkMobile2(mobile) {
|
if (!/(^1[0-9][0-9]{9}$)/.test(mobile)) {
|
return false;
|
}
|
|
return true;
|
}
|
}
|
|
export default new Validator()
|