@type-ddd/zip-code
Version:
This package provides TypeScript type definitions for handling Brazilian Zip Code in Domain-Driven Design contexts
50 lines (49 loc) • 1.49 kB
TypeScript
import { Result, ValueObject } from 'rich-domain';
declare class ZipCode extends ValueObject<string> {
protected static readonly REGEX: RegExp;
protected static readonly MESSAGE: string;
private constructor();
/**
* @returns value as string. always only numbers
* @example 75520140
*/
value(): string;
/**
* @description add hyphen and dot to cpf value.
* @example before "75520140"
* @example after "75520-140"
*/
static addMask(zipCode: string): string;
/**
* @description remove hyphen and dot from cpf value.
* @example before "75520-140"
* @example after "75520140"
*/
static removeSpecialChars(zipCode: string): string;
/**
* @description add special chars to numbers
* @returns zip code as string following pattern xxxxx-xxx
*/
toPattern(): string;
/**
*
* @param value PostalCode as string
* @returns true if value match with pattern and false if do not.
*/
static isValid(value: string): boolean;
/**
*
* @param value PostalCode as string
* @returns true if value match with pattern and false if do not.
*/
static isValidProps(value: string): boolean;
/**
*
* @param value value as string
* @returns instance of ZipCode or throw an error
*/
static init(value: string): ZipCode;
static create(value: string): Result<ZipCode | null>;
}
export { ZipCode };
export default ZipCode;