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    
@skava/ui / src / forms / deps / isValidShippingAddress.ts
Size: Mime:
import { isEmpty } from 'exotic'
import { isAlphaNumericWithSpace } from './isAlphaNumeric'

const matchAlphaNumericSpecialCharacters = /^[ A-Za-z0-9,/#-]*$/
const matchSpaces = /\s/g

function isValidShippingAddress(value: string): boolean {
  const withoutSpaces = String(value).replace(matchSpaces, '')
  if (isEmpty(withoutSpaces)) {
    return false
  } else {
    return (
      isAlphaNumericWithSpace(value) ||
      matchAlphaNumericSpecialCharacters.test(value)
    )
  }
}

function EmptyOrValidShippingAddress(value: string): boolean {
  if (isEmpty(value)) {
    return true
  } else {
    return (
      isValidShippingAddress(value)
    )
  }
}

export { isValidShippingAddress, EmptyOrValidShippingAddress }