-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.d.ts
More file actions
59 lines (59 loc) · 2.02 KB
/
index.d.ts
File metadata and controls
59 lines (59 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/**
*
* @param {string|number} input
* @param {string} [formatType='any']
* @returns A detailed representation of the given input.
*/
export function toJSON(
input: string | number,
formatType?: 'standard' | 'any' | 'dashOnly' | 'noSymbols'
): {
digit: string
formattedValue: string
isFormatValid: boolean
isValid: boolean
serial: string
}
/**
*
* @param {string|number} input - Any string or number
* @param {'standard'|'dashOnly'|'noSymbols'} [formatType="standard"] - One of the listed strings. Defaults to ``standard``
* @returns {string} String formatted according to the ``formatType`` param.
* Removes any invalid character before applying the format.
*
* @example
* format('108646292') // => '10.864.629-2'
* format('108646292', 'dashOnly') // => '10864629-2'
* format('10.864.629-2', 'noSymbols') // => '108646292'
*/
export function format(
input: string | number,
formatType?: 'standard' | 'dashOnly' | 'noSymbols'
): string
/**
*
* @param {string|number} input - Any string or number
* @param {'any'|'standard'|'dashOnly'|'noSymbols'} [formatType="any"] - One of the listed strings. Defaults to ``'any'``.
* @returns {boolean} Returns true when ``input`` matches the given ``formatType`` or any of them if ``formatType='any'`` is given, otherwise false.
* @example
* isFormatValid('108646292', 'standard') // => false
* isFormatValid('108646292', 'any') // => true
* isFormatValid('108646292', 'noSymbols') // => true
*/
export function isFormatValid(
input: string | number,
formatType?: 'any' | 'standard' | 'dashOnly' | 'noSymbols'
): boolean
/**
*
* @param {string|number} input
* @returns {boolean} Returns true when the given input has only valid characters
* is of length two or greater and its digit is valid for the serial number.
* Does not validate neither max length nor input format.
* @example
* isValid('108646292') // => true
* isValid('10.864.629-2') // => true
* isValid('111') // => false
* isValid('1n1') // => false
*/
export function isValid(input: string | number): boolean