This commit is contained in:
2026-06-30 22:21:56 +03:30
parent 8b855e5ee4
commit 4fa2c0d57d
6 changed files with 80 additions and 29 deletions
+16 -2
View File
@@ -32,9 +32,23 @@ import { computed, ref } from 'vue'
import type { Rule } from 'ant-design-vue/es/form'
import { useWalletStore } from '@/store/walletStore'
import {isToken} from "@/utils/index";
import { persianToEnglishDigits } from '@/utils/persianDigits'
export const mobileValidation = (title?: string) => {
return { len: 11, message: `شماره همراه باید 11 رقم باشد` }
export const mobileValidation = (title?: string): Rule => {
const label = title ?? 'شماره تلفن'
return {
validator: (_rule, value) => {
const normalized = persianToEnglishDigits(String(value ?? '').trim())
if (!normalized) {
return Promise.resolve()
}
if (!/^09\d{9}$/.test(normalized)) {
return Promise.reject(`${label} باید با 09 شروع شود و 11 رقم باشد`)
}
return Promise.resolve()
},
trigger: ['change', 'blur'],
}
}
export const required = (title?: string) => {