Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
ui-component-library / src / forms / deps / isValidCoupon.tsx
Size: Mime:
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 }