Repository URL to install this package:
Version:
0.14.1 ▾
|
import { isString, isNumber } from 'exotic'
import isValidLength from './isValidLength'
const matchAlphaNumeric = /^[A-Za-z0-9]+$/
type CouponValueType = string | number
function isValidCoupon(value: CouponValueType): boolean {
const coerced = isNumber(value) ? String(value) : value
const isStringWithLength = isString(coerced) && isValidLength(value, 2, 11) && matchAlphaNumeric.test(value)
return isStringWithLength
}
export { isValidCoupon }