@type-ddd/phone
Version:
Library that provides TypeScript type definitions for handling Phone Numbers in Domain-Driven Design contexts. It facilitates the validation and manipulation of Brazilian phone numbers.
42 lines (41 loc) • 1.34 kB
TypeScript
import { Result, ValueObject } from "rich-domain";
import MobilePhone from "./mobile.value-object";
import HomePhone from "./home.value-object";
import { ddd } from "./ddd.list";
export declare class Phone extends ValueObject<string> {
protected static readonly MESSAGE: string;
toCall: () => string;
number: () => string;
value: () => string;
ddd: () => ddd;
isMobile: () => boolean;
isHome: () => boolean;
uf: () => string;
toPattern: () => string;
/**
*
* @returns DDD only as number
* @example 11
*/
static ddd(phone: string): ddd;
static removeSpecialChars(cell: string): string;
static addMask(cell: string): string;
static isValid(phone: string): boolean;
static isValidProps(phone: string): boolean;
static isMobile(phone: string): boolean;
static isHome(phone: string): boolean;
/**
*
* @param value value as string
* @returns instance of MobilePhone or HomePhone or throw an error
*/
static init(value: string): MobilePhone | HomePhone;
/**
*
* @param value Brazilian Mobile or Home phone number
* @example (XX) 9XXXX-XXXX or (XX) 3XXX-XXXX
* @returns Result of MobilePhone or HomePhone
*/
static create(value: string): Result<MobilePhone | HomePhone | null>;
}
export default Phone;