/** * Parses a brazilian formatted list into an Array. * @example * parseToArray(''); * //=> [] * parseToArray('1'); * //=> ['1'] * parseToArray('1 e 2'); * //=> ['1', '2'] * parseToArray('1, 2, 3, 4 e 5'); * //=> ['1', '2', '3', '4', '5'] * parseToArray('Fernanda, Luana e Ana Carolina'); * //=> ['Fernanda', 'Luana', 'Ana Carolina'] * @param value - A brazilian formatted list. */ declare const parseToArray: (value: string) => string[]; /** * Parses a brazilian formatted date into a Date instance. * @example ```js * parseToDate('28/03/1996') * //=> '1996-03-28T03:00:00.000Z' * * parseToDate('31/02/2018') * //=> throws Error('Value "31/02/2018" is an invalid date.') * ``` * @param value - A date in DD/MM/YYYY. */ declare const parseToDate: (value: string) => Date; /** * Parses brazilian formatted number to number. * @example * parseToNumber('10') * //=> 10 * parseToNumber('-1.299') * //=> -1299 * parseToNumber('0,981') * //=> 0.981 * parseToNumber('19.898,1298') * //=> 19898.1298 * @param value - A brazilian formatted number. */ declare const parseToNumber: (value: string) => number; /** * Check if value is a valid CAEPF. * @example ```js * isCAEPF('41142260000101') * //=> true * * isCAEPF('411.422.600/001-01') * //=> true * * isCAEPF('111.111.111/111-11') * //=> false * * isCAEPF('411407182') * //=> false * * ``` * @param value - A text containing a CAEPF. */ declare const isCAEPF: (value: string) => boolean; /** * Check if value is a valid CEP. * @example ```js * isCEP('50.833-000') * //=> true * * isCEP('02998-050') * //=> true * * isCEP('00000000') * //=> true * * isCEP('0') * //=> false * * isCEP('1982891928981982198') * //=> false * ``` * @param value - A text containing a CEP. */ declare const isCEP: (value: string) => boolean; /** * Check if value is a valid CNPJ (numeric or alphanumeric). * Accepts both traditional numeric CNPJs and new alphanumeric CNPJs (valid from 2026). * @example ```js * isCNPJ('41142260000189') * //=> true * * isCNPJ('45.723.174/0001-10') * //=> true * * isCNPJ('AB12CD34EF5602') * //=> true * * isCNPJ('AB.12C.D34/EF56-02') * //=> true * * isCNPJ('411407182') * //=> false * * isCNPJ('11.111.111/1111-11') * //=> false * ``` * @param value - A text containing a CNPJ. */ declare const isCNPJ: (value: string) => boolean; /** * Check if value is a valid alphanumeric CNPJ. * @example ```js * isCNPJAlphanumeric('AB12CD34EF5602') * //=> true * * isCNPJAlphanumeric('AB.12C.D34/EF56-02') * //=> true * * isCNPJAlphanumeric('AB12CD34EF5600') * //=> false * ``` * @param value - A text containing an alphanumeric CNPJ. */ declare const isCNPJAlphanumeric: (value: string) => boolean; /** * Check if value is a valid CPF. * @example ```js * isCPF('366.418.768-70') * //=> true * * isCPF('36641876870') * //=> true * * isCPF('213.198.013-20') * //=> false * * isCPF('2131201872781') * //=> false * * isCPF('11111111111') * //=> false * ``` * @param value - A text containing a CPF. */ declare const isCPF: (value: string) => boolean; /** * Check if a brazilian formatted date is valid. * @example ```js * isDate('03/08/2017') * //=> true * * isDate('28/13/2017') * //=> false * * isDate('03-08-2017') * //=> false * * isDate('31/03/18') * //=> false * ``` * @param value - A date in DD/MM/YYYY. */ declare const isDate: (value: string) => boolean; /** * Check if value is a valid DDD. * @example ```js * isDDD('81') * //=> true * * isDDD('10') * //=> false * * isDDD('A#') * //=> false * ``` * @param code */ declare const isDDD: (code: string) => boolean; /** * Check if value is a valid brazilian phone number. It can check a wide * variety of formats optionally with DDI, DDD and the ninth digit. * * @example ```js * isPhone('+55 (11) 98273-1182') * //=> true * * isPhone('11 98273 1182') * //=> true * * isPhone('1139723768') * //=> true * * isPhone('(23) 3972-3768') * //=> false * * isPhone('(13) 65093-2093') * //=> false * * isPhone('(81) 555 178') * //=> false * ``` * @param value */ declare const isPhone: (value: string) => boolean; /** * Check if a value is a valid CPF or CNPJ (numeric or alphanumeric) * Accepts traditional numeric CPFs and CNPJs, as well as new alphanumeric CNPJs (valid from 2026). * @example ```js * isCPFOrCNPJ('366.418.768-70') * //=> true * * isCPFOrCNPJ('36641876870') * //=> true * * isCPFOrCNPJ('213.198.013-20') * //=> false * * isCPFOrCNPJ('2131201872781') * //=> false * * isCPFOrCNPJ('11111111111') * //=> false * * isCPFOrCNPJ('41142260000189') * //=> true * * isCPFOrCNPJ('45.723.174/0001-10') * //=> true * * isCPFOrCNPJ('AB12CD34EF5602') * //=> true * * isCPFOrCNPJ('AB.12C.D34/EF56-02') * //=> true * * isCPFOrCNPJ('411407182') * //=> false * * isCPFOrCNPJ('11.111.111/1111-11') * //=> false * ``` * @param value - A text containing a CPF or CNPJ */ declare const isCPFOrCNPJ: (value: string) => boolean; /** * Formats a number into money (BRL) format. * @example ```js * formatToBRL(1928.93) * //=> 'R$ 1.928,93' * * formatToBRL('9211928.18203') * //=> 'R$ 9.211.928,18' * * formatToBRL(-18.49) * //=> 'R$ -18,49' * ``` * @param value BRL value. */ declare const formatToBRL: (value: number | string) => string; /** * Formats step-by-step a `string` value into a CAEPF. * @example ```js * formatToCAEPF('1234567') * //=> '123.456.7' * * formatToCAEPF('12345678900199') * //=> '123.456.789/001-99' * * formatToCAEPF('00.000.0.0--0-0000.00') * //=> '000.000.000/000-00' * * formatToCAEPF('123.456.789/001-99') * //=> '123.456.789/001-99' * ``` * @param value - A `string` value of a CAEPF. */ declare const formatToCAEPF: (value: string) => string; /** * Options for `formatToCapitalizedd` function. */ type Options = { wordsToKeepLowerCase?: string[]; wordsToKeepUpperCase?: string[]; trimTrailingWhiteSpaces?: boolean; }; /** * Capitaliza as palavras de um texto, com exceção das palavras configuradas * para serem deixadas em caixa-alta ou em caixa-baixa (menos a primeira palavra * que não será caixa-baixa mesmo se configurada como). * * @example ```js * formatToCapitalized('SERVIDOR PÚBLICO MUNICIPAL') * //=> 'Servidor Público Municipal' * * formatToCapitalized(' os PrimEIROS HOMens da tERra', { * wordsToKeepLowerCase: ['os', 'da'] * }) * //=> 'Os Primeiros Homens da Terra' * * formatToCapitalized('nova tv foi lançada', { * wordsToKeepUpperCase: ['tv'] * }) * //=> 'Nova TV Foi Lançada' * * formatToCapitalized(' com espaços antes e depois ', { * trimTrailingWhiteSpaces: false * }) * //=> ' Com Espaços Antes e Depois ' * ``` * @param value - A `string` to capitalize */ declare const formatToCapitalized: (value: string, { wordsToKeepLowerCase, wordsToKeepUpperCase, trimTrailingWhiteSpaces, }?: Options) => string; /** * Format a `string` number sequence into CEP format. * @example ```js * formatToCEP('15998030') * //=> '15998-030' * * formatToCEP('02999') * //=> '02999' * ``` * @param value A `string` with CEP numbers. */ declare const formatToCEP: (value: string) => string; /** * Formats step-by-step a `string` value into a CNPJ. * @example ```js * formatToCNPJ('128781') * //=> '12.878.1' * * formatToCNPJ('32284981000138') * //=> '32.284.981/0001-38' * * formatToCNPJ('00.0.000.00.00--00-00') * //=> '00.000.000/0000-00' * ``` * @param value - A `string` value of a CNPJ. */ declare const formatToCNPJ: (value: string) => string; /** * Formats step-by-step a `string` value into an alphanumeric CNPJ. * Supports both numeric and alphanumeric CNPJs in the format AA.AAA.AAA/AAAA-99. * @example ```js * formatToCNPJAlphanumeric('AB12CD34EF5602') * //=> 'AB.12C.D34/EF56-02' * * formatToCNPJAlphanumeric('AB.12C.D34/EF56-02') * //=> 'AB.12C.D34/EF56-02' * * formatToCNPJAlphanumeric('32284981000138') * //=> '32.284.981/0001-38' * * formatToCNPJAlphanumeric('XY987') * //=> 'XY.987' * ``` * @param value - A `string` value of an alphanumeric CNPJ. */ declare const formatToCNPJAlphanumeric: (value: string) => string; /** * Formats step-by-step a `string` value into a CPF. * @example ```js * formatToCPF('00000000') * //=> '000.000.00' * * formatToCPF('00000000000') * //=> '000.000.000-00' * * formatToCPF('366.418.768-70') * //=> '366.418.768-70' * ``` * @param value - A `string` value of a CPF. */ declare const formatToCPF: (value: string) => string; /** * Formats step-by-step a `string` value to CPF or CNPJ depending on its length. * Supports numeric CPFs, numeric CNPJs, and alphanumeric CNPJs. * @example * formatToCPFOrCNPJ('00000000') * //=> '000.000.00' * * formatToCPFOrCNPJ('366.418.768-70') * //=> '366.418.768-70' * * formatToCPFOrCNPJ('32284981000138') * //=> '32.284.981/0001-38' * * formatToCPFOrCNPJ('00.0.000.00.00--00-00') * //=> '00.000.000/0000-00' * * formatToCPFOrCNPJ('AB12CD34EF5602') * //=> 'AB.12C.D34/EF56-02' * @param value - A `string` value of a CPF or CNPJ. */ declare const formatToCPFOrCNPJ: (value: string) => string; /** * Formats a Date instance to brazilian format, DD/MM/YYYY. * @example ```js * formatToDate(new Date(2002, 7, 21)) * //=> '21/08/2002' * * formatToDate(new Date()) * //=> '08/09/2018' * ``` * @param value - A Date instance. */ declare const formatToDate: (value: Date) => string; /** * Formats a Date instance to brazilian format of date and time, DD/MM/YYYY HH:mm. * @example ```js * formatToDateTime(new Date(2002, 7, 21, 18, 30)) * //=> '21/08/2002 18:30' * ``` * @param value - A Date instance. */ declare const formatToDateTime: (value: Date) => string; /** * Formats a phone value into brazilian common phone formats. * @example ```js * formatToGenericPhone('23456789') * //=> '2345-6789' * * formatToGenericPhone('923456789') * //=> '92345-6789' * * formatToGenericPhone('21923456789') * //=> '(21) 92345-6789' * * formatToGenericPhone('021923456789') * //=> '021 92345-6789' * * formatToGenericPhone('5521923456789') * //=> '+55 21 92345-6789' * ``` * @param value * @param countryCodeLength */ declare const formatToGenericPhone: (value: string, countryCodeLength?: number) => string; /** Options object for {@link formatToHiddenDigits} function. */ type FormatToHiddenDigitsOptions = { /** * The range of digits replaced by {@link FormatToHiddenDigitsOptions.hider} * character. It can be both a tuple of numbers or a single number. * * @example ```js * formatToHiddenDigits("00.000-00", { range: 2 }); * //=> "**.000-00" * * formatToHiddenDigits("00.000-00", { range: -2 }); * //=> "00.000-**" * * formatToHiddenDigits("00.000-00", { range: [1, 4] }); * //=> "0*.***-00" * ``` * * @default 3 */ range?: number | [number, number]; /** * The character used as replacement for digits in within * {@link FormatToHiddenDigitsOptions.range}. * * @example ```js * formatToHiddenDigits("00.000-00", { hider: "-" }); * //=> "--.-00-00" * * formatToHiddenDigits("00.000-00", { hider: " " }); * //=> " . 00-00" * * formatToHiddenDigits("00.000-00", { hider: "#" }); * //=> "##.#00-00" * ```js * * @default "*" */ hider?: string; }; /** * Formats a `string` value with digits by replacing the digits within the * range using the hider character as replacement. * * @example ```js * formatToHiddenDigits('00.000-000') * //=> '**.*00-000' * * formatToHiddenDigits('03/04/2002', { hider: '-' }) * //=> '--/-4/2002' * * formatToHiddenDigits('111.111.111-11', { range: [4, 9] }) * //=> '111.***.***-11' * * formatToHiddenDigits('12.345.678-9', { hider: '#', range: 5 }) * //=> '##.###.678-9' * * formatToHiddenDigits('52.715.348/0001-69', { hider: '@', range: -9 }) * //=> '52.715.@@@/@@@@-@@' * ``` * * @param value - A `string` with digits, with or without a mask. * @param options - The options object. */ declare const formatToHiddenDigits: (value: string, options?: FormatToHiddenDigitsOptions) => string; /** * Formats an Array into brazilian formatted list. * @example * formatToList(['Vitor', 'William', 'Fernando']) * //=> 'Vitor, William e Fernando' * * formatToList([]) * // => '' * * formatToList(['1', '2']) * // => '1 e 2' * * formatToList(['Direito Civil']) * //=> 'Direito Civil' * @param value - An array of string values. */ declare const formatToList: (value: string[]) => string; /** * Formats a number to brazilian formatted number. * @example * formatToNumber(0) * //=> '0' * formatToNumber(-1299) * //=> '-1.299' * formatToNumber(.981) * //=> '0,981' * formatToNumber('19898.1298') * //=> '19.898,1298' * @param value - Number value to be formatted. */ declare const formatToNumber: (value: number | string) => string; /** * Formats a phone value into brazilian common phone formats. * @example ```js * formatToPhone('11') * //=> '(11' * * formatToPhone('11971626') * //=> '(11) 9716-26' * * formatToPhone('11971626799') * //=> '(11) 97162-6799' * ``` * @param value */ declare const formatToPhone: (value: string) => string; /** * Progressively formats a `string` into a RG. * @example ```js * formatToRG('00000000A', 'SP') * //=> '00.000.000-A' * * formatToRG('00.00.0000-0', 'RJ') * //=> '00.000.000-0' * * formatToRG('MG-14.808.688', 'MG') * //=> 'MG-14.808.688' * ``` * @param value - A `string` representing an RG. * @param state - Brazilian state which defines RG format. */ declare const formatToRG: (value: string, state?: string) => string; export { type FormatToHiddenDigitsOptions, formatToBRL, formatToCAEPF, formatToCEP, formatToCNPJ, formatToCNPJAlphanumeric, formatToCPF, formatToCPFOrCNPJ, formatToCapitalized, formatToDate, formatToDateTime, formatToGenericPhone, formatToHiddenDigits, formatToList, formatToNumber, formatToPhone, formatToRG, isCAEPF, isCEP, isCNPJ, isCNPJAlphanumeric, isCPF, isCPFOrCNPJ, isDDD, isDate, isPhone, parseToArray, parseToDate, parseToNumber };