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
Importimport { validateFullName } from 'progressive-web-sdk/dist/utils/validation
Returns:
Boolean
Parameter | Type | Description |
---|---|---|
fullName | string | The 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.
Importimport { validateCCExpiry } from 'progressive-web-sdk/dist/utils/validation
Returns:
Boolean
Parameter | Type | Description |
---|---|---|
ccExpiry | string | The 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
Importimport { validateCCNumber } from 'progressive-web-sdk/dist/utils/validation
Returns:
Boolean
Parameter | Type | Description |
---|---|---|
ccNumber | string | The 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
Importimport { validatePostalCode } from 'progressive-web-sdk/dist/utils/validation
Returns:
Boolean
Parameter | Type | Description |
---|---|---|
postalCode | string | The postal code to validate |
countryId | string | The 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