All files / utils isPossibleChineseMobilePhoneNumber.ts

100% Statements 2/2
100% Branches 0/0
100% Functions 1/1
100% Lines 2/2

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20    24x                             21x    
import { phoneNumberRegExpBuilder } from '../regexp'
 
const regExp = phoneNumberRegExpBuilder.build({ exact: true })
 
/**
 * 检测传入的值是否可能是中国的手机号码。
 *
 * @public
 * @param value 要检测的值
 * @returns 返回检测结果
 * @example
 * ```typescript
 * isPossibleChineseMobilePhoneNumber('10086') // => false
 * isPossibleChineseMobilePhoneNumber('18087030088') // => true
 * ```
 */
export function isPossibleChineseMobilePhoneNumber(value: string | number) {
  return regExp.test(String(value))
}