-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathexport.flow.js
160 lines (141 loc) · 3.98 KB
/
export.flow.js
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/**
* Flowtype definitions for index.ts
* Generated by Flowgen from a Typescript Definition
* Flowgen v1.10.0
*/
/**
* Object-oriented API for Norwegian National ID Validator
* @example ```javascript
* import { NorwegianId } from 'norwegian-national-id-validator';
*
* const valid = NorwegianId('0000000000');
* ```
* @param idNumber norwegian social security number
*/
declare export var NorwegianId: any; // /* NO PRINT IMPLEMENTED: ArrowFunction */ any
/**
* Calculated the difference betweeen two dates.
* @param startDate Date instance
* @param endDate Date instance
* @private
*/
declare export function diffYears(startDate: Date, endDate: Date): void;
/**
* Checks if a date is valid against another
* @param date Date instance
* @param expectedYear
* @param expectedMonth
* @param expectedDay
*/
declare export function isValidDate(
date: Date,
expectedYear: string,
expectedMonth: string,
expectedDay: string
): boolean;
/**
* In Norway there is several different ID numbers
*/
declare export var IDNumberType: {|
+BirthNumber: 0, // 0
+DNumber: 1, // 1
+HNumber: 2, // 2
+FHNumber: 3 // 3
|};
/**
* Birth numbers, D-number and H-number contains information about gender
*/
declare export var Gender: {|
+Male: 0, // 0
+Female: 1 // 1
|};
/**
* Checks if the given value is a valid Norwegian national identity number.
* @example ```javascript
* import { validateNorwegianIdNumber } from 'norwegian-national-id-validator';
* const valid = validateNorwegianIdNumber(0000000000);
* ```
* @param idNumber social security number
* @returns `true` for valid, and `false` for invalid ID-number.
*/
declare export function validateNorwegianIdNumber(idNumber: string): boolean;
/**
* Find possible age of person based of IDNumber
* @param elevenDigits Identification number
*/
declare export function possibleAgesOfPersonWithIdNumber(
elevenDigits: string
): number[];
/**
* Returns the age of a person with given Norwegian national identity number.
* Returns `undefined` when birth date could not be determined (e.g. for FH-numbers and invalid ID-numbers).
* @param elevenDigits Identification number
*/
declare export function possibleAgeOfPersonWithIdNumber(
elevenDigits: string
): number | void;
/**
* Check if idNumber contains birth date
* @param elevenDigits idNumber
*/
declare export function idNumberContainsBirthDate(
elevenDigits: string
): boolean;
/**
* Get possible birth date from IdNumber
* @param elevenDigits IdNumber
*/
declare function possibleBirthDateOfIdNumber(elevenDigits: string): Date | void;
/**
* Get the ID number kind/type. This function does not validate, so
* should be combined with {@linkcode validateNorwegianIdNumber}.
* @example ```javascript
* import { idNumberType, validateNorwegianIdNumber } from 'norwegian-national-id-validator';
* if (validateNorwegianIdNumber(0000000000)) {
* const type = idNumberType(00000000000);
* }
* ```
* @param elevenDigits IdNumber
*/
declare function idNumberType(
elevenDigits: string
): $Values<typeof IDNumberType>;
/**
* Get possible birth date from BirthNumber
* @param elevenDigits BirthNumber
*/
declare function possibleBirthDateOfBirthNumber(
elevenDigits: string
): Date | void;
/**
* Get possible birth date from HNumber
* @param elevenDigits HNumber
*/
declare function possibleBirthDateOfHNumber(elevenDigits: string): Date | void;
/**
* Get possible birth date from DNumber
* @param elevenDigits DNumber
*/
declare function possibleBirthDateOfDNumber(elevenDigits: string): Date | void;
/**
* @private
*/
declare function getBirthDate(elevenDigitsWithDDMMYY: string): Date | void;
/**
* @private
*/
declare function isValidCheckDigits(elevenDigits: string): boolean;
/**
* @private
*/
declare function isValidCheckDigit(
staticSequence: number[],
elevenDigits: number[]
): boolean;
/**
* Returns the gender based of id number
* @param elevenDigits id number
*/
declare export function getGender(
elevenDigits: string
): $Values<typeof Gender> | void;