UNPKG

angular-phone-utils-lib

Version:

Angular library for phone number formatting and validation based on libphonenumber-js

45 lines (44 loc) 1.26 kB
import { ValidatorFn } from "@angular/forms"; export declare class PhoneUtilsService { /** * Transform a given phone number to international format * * @param value Phone numer * @param country Two-letters country code */ getInternational(value: string, country: string): string; /** * Transform a given phone number to its national format * * @param value Phone numer * @param country Two-letters country code */ getNational(value: string, country: string): string; /** * International format without inner spaces (PNF.E164) * * Instead of "+359 88 123" it will return "+35988123" * * @param value * @param country */ getPlain(value: string, country: string): string; /** * Is valid phone number? * * The method will return true when arguments relates to a * phone number from the selected country. * * @param value * @param country */ isValid(value: string, country: string): boolean; /** * Reactive form validator * * Will set *phoneInvalid* property in related form control error's object. * * @param country */ isValidFormControl(country: string): ValidatorFn; }