feat: add global validator for phone number

pull/50/head
farid saravi 4 years ago
parent 7413c75af3
commit 7cc65dea0f

@ -5,4 +5,16 @@ import fa from "@Global/utils/vee-validate/locale/fa";
import "@Global/utils/vee-validate/newRules"; import "@Global/utils/vee-validate/newRules";
Vue.use(VeeValidate); Vue.use(VeeValidate);
const phoneRule = {
getMessage(field, args) {
return `The ${field} must be either a valid phone number`;
},
validate(value, args) {
const PHONE_REG = /^0\d{2,3}\d{8}$/;
return PHONE_REG.test(value);
}
};
VeeValidate.Validator.extend('phone', phoneRule);
Validator.localize("fa", fa); Validator.localize("fa", fa);

Loading…
Cancel
Save