PATH:
opt
/
bitninja-dispatcher
/
node_modules
/
class-validator
/
esm2015
/
decorator
/
string
import { buildMessage, ValidateBy } from '../common/ValidateBy'; import { parsePhoneNumberFromString } from 'libphonenumber-js'; export const IS_PHONE_NUMBER = 'isPhoneNumber'; /** * Checks if the string is a valid phone number. To successfully validate any phone number the text must include * the intl. calling code, if the calling code wont be provided then the region must be set. * * @param value the potential phone number string to test * @param region 2 characters uppercase country code (e.g. DE, US, CH) for country specific validation. * If text doesn't start with the international calling code (e.g. +41), then you must set this parameter. */ export function isPhoneNumber(value, region) { try { const phoneNum = parsePhoneNumberFromString(value, region); const result = phoneNum === null || phoneNum === void 0 ? void 0 : phoneNum.isValid(); return !!result; } catch (error) { // logging? return false; } } /** * Checks if the string is a valid phone number. To successfully validate any phone number the text must include * the intl. calling code, if the calling code wont be provided then the region must be set. * * @param region 2 characters uppercase country code (e.g. DE, US, CH) for country specific validation. * If text doesn't start with the international calling code (e.g. +41), then you must set this parameter. */ export function IsPhoneNumber(region, validationOptions) { return ValidateBy({ name: IS_PHONE_NUMBER, constraints: [region], validator: { validate: (value, args) => isPhoneNumber(value, args.constraints[0]), defaultMessage: buildMessage(eachPrefix => eachPrefix + '$property must be a valid phone number', validationOptions), }, }, validationOptions); } //# sourceMappingURL=IsPhoneNumber.js.map
[-] IsDecimal.js
[edit]
[-] IsFirebasePushId.js.map
[edit]
[-] IsByteLength.js
[edit]
[-] IsISBN.js.map
[edit]
[-] IsLowercase.js
[edit]
[-] IsUrl.js
[edit]
[-] IsDataURI.js.map
[edit]
[-] IsISIN.js.map
[edit]
[-] IsPort.js.map
[edit]
[-] IsLowercase.js.map
[edit]
[-] IsJSON.js
[edit]
[-] IsFQDN.js.map
[edit]
[-] IsLocale.js.map
[edit]
[-] IsDateString.js
[edit]
[-] IsBooleanString.js
[edit]
[-] IsUppercase.js
[edit]
[-] IsUppercase.js.map
[edit]
[-] IsCreditCard.js
[edit]
[-] IsIBAN.js.map
[edit]
[-] IsLocale.js
[edit]
[-] IsMilitaryTime.js
[edit]
[-] IsAlphanumeric.js
[edit]
[-] IsHexColor.js
[edit]
[-] Contains.js.map
[edit]
[-] IsHalfWidth.js
[edit]
[-] IsHSL.js
[edit]
[-] IsNumberString.js.map
[edit]
[-] IsNumberString.js
[edit]
[-] IsPhoneNumber.js
[edit]
[+]
..
[-] IsMacAddress.js
[edit]
[-] IsCurrency.js
[edit]
[-] IsBtcAddress.js
[edit]
[-] IsBIC.js.map
[edit]
[-] IsUrl.js.map
[edit]
[-] IsISRC.js
[edit]
[-] IsUUID.js
[edit]
[-] IsPort.js
[edit]
[-] IsRFC3339.js
[edit]
[-] IsSemVer.js.map
[edit]
[-] IsAscii.js.map
[edit]
[-] Length.js.map
[edit]
[-] IsISO8601.js.map
[edit]
[-] IsISO31661Alpha3.js
[edit]
[-] IsSurrogatePair.js.map
[edit]
[-] IsIBAN.js
[edit]
[-] IsAscii.js
[edit]
[-] IsOctal.js.map
[edit]
[-] IsFullWidth.js
[edit]
[-] IsCurrency.js.map
[edit]
[-] MaxLength.js
[edit]
[-] IsFirebasePushId.js
[edit]
[-] IsHash.js
[edit]
[-] IsAlphanumeric.js.map
[edit]
[-] IsBase64.js.map
[edit]
[-] IsCreditCard.js.map
[edit]
[-] IsRgbColor.js
[edit]
[-] MinLength.js.map
[edit]
[-] IsISSN.js
[edit]
[-] IsPassportNumber.js
[edit]
[-] IsFQDN.js
[edit]
[-] IsVariableWidth.js.map
[edit]
[-] IsMimeType.js
[edit]
[-] IsJWT.js.map
[edit]
[-] IsPassportNumber.js.map
[edit]
[-] IsBooleanString.js.map
[edit]
[-] IsPostalCode.js.map
[edit]
[-] IsISO31661Alpha2.js.map
[edit]
[-] IsMagnetURI.js.map
[edit]
[-] IsISO31661Alpha3.js.map
[edit]
[-] IsSurrogatePair.js
[edit]
[-] IsRgbColor.js.map
[edit]
[-] Length.js
[edit]
[-] IsBase64.js
[edit]
[-] IsDataURI.js
[edit]
[-] IsVariableWidth.js
[edit]
[-] IsByteLength.js.map
[edit]
[-] IsISO8601.js
[edit]
[-] MinLength.js
[edit]
[-] Contains.js
[edit]
[-] IsEAN.js
[edit]
[-] IsHalfWidth.js.map
[edit]
[-] IsDateString.js.map
[edit]
[-] IsIP.js.map
[edit]
[-] IsEthereumAddress.js
[edit]
[-] NotContains.js
[edit]
[-] IsIdentityCard.js
[edit]
[-] IsEmail.js.map
[edit]
[-] IsAlpha.js
[edit]
[-] IsAlpha.js.map
[edit]
[-] IsEAN.js.map
[edit]
[-] IsHash.js.map
[edit]
[-] IsBase32.js.map
[edit]
[-] Matches.js.map
[edit]
[-] IsIP.js
[edit]
[-] MaxLength.js.map
[edit]
[-] IsMacAddress.js.map
[edit]
[-] IsUUID.js.map
[edit]
[-] IsBase32.js
[edit]
[-] IsISO31661Alpha2.js
[edit]
[-] IsEthereumAddress.js.map
[edit]
[-] IsISRC.js.map
[edit]
[-] IsDecimal.js.map
[edit]
[-] IsJSON.js.map
[edit]
[-] IsBtcAddress.js.map
[edit]
[-] IsISSN.js.map
[edit]
[-] IsHexadecimal.js.map
[edit]
[-] IsISBN.js
[edit]
[-] IsHexadecimal.js
[edit]
[-] IsOctal.js
[edit]
[-] IsMultibyte.js
[edit]
[-] IsBIC.js
[edit]
[-] IsHSL.js.map
[edit]
[-] NotContains.js.map
[edit]
[-] IsFullWidth.js.map
[edit]
[-] IsHexColor.js.map
[edit]
[-] IsMobilePhone.js
[edit]
[-] IsEmail.js
[edit]
[-] IsISIN.js
[edit]
[-] IsMongoId.js.map
[edit]
[-] IsMilitaryTime.js.map
[edit]
[-] IsMultibyte.js.map
[edit]
[-] IsPhoneNumber.js.map
[edit]
[-] IsSemVer.js
[edit]
[-] IsRFC3339.js.map
[edit]
[-] IsMobilePhone.js.map
[edit]
[-] Matches.js
[edit]
[-] IsJWT.js
[edit]
[-] IsPostalCode.js
[edit]
[-] IsIdentityCard.js.map
[edit]
[-] IsMongoId.js
[edit]
[-] IsMagnetURI.js
[edit]
[-] IsMimeType.js.map
[edit]