fix persian number in input
This commit is contained in:
@@ -1,11 +1,4 @@
|
||||
const PERSIAN_DIGITS = '۰۱۲۳۴۵۶۷۸۹'
|
||||
const ARABIC_DIGITS = '٠١٢٣٤٥٦٧٨٩'
|
||||
|
||||
function toAsciiDigits(value: string): string {
|
||||
return value
|
||||
.replace(/[۰-۹]/g, (d) => String(PERSIAN_DIGITS.indexOf(d)))
|
||||
.replace(/[٠-٩]/g, (d) => String(ARABIC_DIGITS.indexOf(d)))
|
||||
}
|
||||
import { parseNumericValue, sanitizeNumericString } from '@core/utils/convert'
|
||||
|
||||
/** پارس مبلغ محدودیت سفارش — ارقام فارسی/عربی و جداکننده هزارگان */
|
||||
export function parseOrderLimitCashValue(value: unknown): number | undefined {
|
||||
@@ -13,12 +6,12 @@ export function parseOrderLimitCashValue(value: unknown): number | undefined {
|
||||
return undefined
|
||||
}
|
||||
|
||||
const raw = toAsciiDigits(String(value).trim().replace(/[,\s٬]/g, ''))
|
||||
const raw = sanitizeNumericString(value, { allowDecimal: false })
|
||||
if (raw === '') {
|
||||
return undefined
|
||||
}
|
||||
|
||||
const num = Number(raw)
|
||||
const num = parseNumericValue(raw)
|
||||
if (!Number.isFinite(num) || num < 0) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user