menu
Menu
Mobify DevCenter
search_icon_focus

Validation

progressive-web-sdk/dist/utils/validation

validateFullName(fullName)

Validates that the given full name has at least two “words” (regex ‘\w’) separated by at least one space

Import
import { validateFullName } from 'progressive-web-sdk/dist/utils/validation

Returns:

Boolean

ParameterTypeDescription
fullNamestringThe full name to validate

Example

import {validateFullName} from 'progressive-web-sdk/dist/utils/validation'
validateFullName('John Smith')
// true

validateCCExpiry(ccExpiry)

Checks to see if a credit card has expired given the expiry date.

Import
import { validateCCExpiry } from 'progressive-web-sdk/dist/utils/validation

Returns:

Boolean

ParameterTypeDescription
ccExpirystringThe numeric date string with the format “mmyy”

Example

import {validateCCExpiry} from 'progressive-web-sdk/dist/utils/validation'
validateCCExpiry('0922')
// true

validateCCNumber(ccNumber)

Validates the given credit card number

Import
import { validateCCNumber } from 'progressive-web-sdk/dist/utils/validation

Returns:

Boolean

ParameterTypeDescription
ccNumberstringThe credit card number to validate

Example

import {validateCCNumber} from 'progressive-web-sdk/dist/utils/validation'
validateCCNumber('375556917985515')
// true

validatePostalCode(postalCode, countryId)

Validates the given postal code according to the rules for the given country

Import
import { validatePostalCode } from 'progressive-web-sdk/dist/utils/validation

Returns:

Boolean

ParameterTypeDescription
postalCodestringThe postal code to validate
countryIdstringThe country to validate for (country is any ISO-3166 “alpha-2” code)

Example

import {validatePostalCode} from 'progressive-web-sdk/dist/utils/validation'
validatePostalCode('A1A 1A1', 'CA')
// true