diff --git a/resources/js/Global/plugins/veeValidate.js b/resources/js/Global/plugins/veeValidate.js index 4c0f9cf..c09e85a 100644 --- a/resources/js/Global/plugins/veeValidate.js +++ b/resources/js/Global/plugins/veeValidate.js @@ -5,4 +5,16 @@ import fa from "@Global/utils/vee-validate/locale/fa"; import "@Global/utils/vee-validate/newRules"; 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);