ts
import { validatePhone } from "@arkyn/server/validatePhone";
libphonenumber-js to be installed as a peer dependency:bash
bun add libphonenumber-js
libphonenumber-js to validate and analyze the provided phone number and
checks if there is a country supported by @arkyn/templates corresponding to the number's code/ISO.isValidPhoneNumber to quickly discard invalid inputs.iso: "BR"), the project's masking ecosystem accepts variations with or without the
ninth digit when applicable, but the base validation here depends on libphonenumber-js and the configured country templates.rawPhone (required): The phone number to validate. It can contain an international code (e.g., +5511999999999)libphonenumber-js.stringboolean, true if the number is considered valid for any country present in the templates; otherwise false.false when the number is invalid or
when the country is not supported. Any error not handled by libphonenumber-js will be propagated through the runtime.ts
import { validatePhone } from "@arkyn/server/validatePhone";validatePhone("+5532912345678"); // true (e.g., valid Brazilian number)validatePhone("+553212345678"); // true (variation without 9th digit where applicable)validatePhone("+19706574614"); // true (e.g., valid format for American Samoa / US range)validatePhone("+55329123456178"); // false (number too long / invalid)validatePhone("+55123456789"); // false (invalid number for BR)
isValidPhoneNumber from libphonenumber-js, this ensures that the format and length are consistent with international rules.iso) to one of the countries present in@arkyn/templates (countries). If the country is not in the list of templates, the function returns false.validatePhone with findCountryMask and custom rules from your frontend.findCountryMask, selects the display mask by country.formatToPhone, formats a number according to the country mask.