import { BASE52_ALPHABET } from './Constants' export const isObjectIdString = (str: string) => { return /^[0-9a-fA-F]{24}$/.test(str) } // check if a string is a valid share code // alphabet:'3fBCM8j17XNA9xYun4wmLWep2oHFlhPcgyEJskqOz6GK0UtV5ZRaDSvrTbidQI' export const isValidShareCode = (str: string) => { let reg = new RegExp(`^[${BASE52_ALPHABET}]{10,11}$`) return reg.test(str) } export const isValidVoucherCode = (str: string) => { let reg = new RegExp(`^[${BASE52_ALPHABET}]{12}$`) return reg.test(str) } // check if a string is a valid day tag, like 20240408 export const isValidDayTag = (str: string) => { return /^[0-9]{8}$/.test(str) } export const formatNumShow = (num: number) => { if (num >= 10) { return Math.round(num) + '' } else if (num === 0) { return '0' } else { return num.toFixed(1) } }