@stbmoz-onboarding/core 1.0.21 → 1.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,15 +6,21 @@ export const contractRegimes = [
6
6
  },
7
7
  {
8
8
  value: "DETERMINATED",
9
+ pt: "Determinado",
10
+ en: "Determinated"
11
+ },
12
+ {
13
+ value: "TEMPORARY",
9
14
  pt: "Temporário",
10
15
  en: "Temporary"
11
- },
16
+ }
12
17
  ]
13
18
 
14
19
 
15
20
  export const contractRegime = {
16
21
  indeterminated: "INDETERMINATED",
17
- determinated: "DETERMINATED"
22
+ determinated: "DETERMINATED",
23
+ temporary: "TEMPORARY"
18
24
  }
19
25
 
20
- export default contractRegimes
26
+ export default contractRegimes
@@ -1,19 +1,19 @@
1
1
  export const idDocuments = [
2
2
  {
3
- value: "BI",
3
+ value: 2,
4
4
  pt: "Bilhete de Identidade",
5
5
  en: "Identity card"
6
6
  },
7
7
  {
8
- value: "PASSPORT",
8
+ value: 1,
9
9
  pt: "Passaporte",
10
10
  en: "Passport"
11
11
  }
12
12
  ];
13
13
 
14
14
  export const idDocument = {
15
- id: "BI",
16
- passport: "PASSPORT"
15
+ id: 2,
16
+ passport: 1
17
17
  }
18
18
 
19
19
  export default idDocuments
@@ -2,7 +2,7 @@ export { default as academicLevels } from './academicLevels';
2
2
  export * from './academicLevels';
3
3
  export { default as activities } from './activities';
4
4
  export * from './activities';
5
- export { default as contractTypes } from './contractTypes';
5
+ export { default as contractRegimes } from './contractTypes';
6
6
  export * from './contractTypes';
7
7
  export { default as employmentTypes } from './employmentTypes';
8
8
  export * from './employmentTypes';
@@ -1,6 +1,6 @@
1
1
  export const maritalStatuses = [
2
2
  {
3
- value: 'SINGLE',
3
+ value: 1,
4
4
  pt: {
5
5
  MALE: 'Solteiro',
6
6
  FEMALE: 'Solteira',
@@ -12,7 +12,7 @@ export const maritalStatuses = [
12
12
 
13
13
  },
14
14
  {
15
- value: 'MARRIED',
15
+ value: 2,
16
16
  pt: {
17
17
  MALE: 'Casado',
18
18
  FEMALE: 'Casada',
@@ -23,7 +23,7 @@ export const maritalStatuses = [
23
23
  }
24
24
  },
25
25
  {
26
- value: 'DIVORCED',
26
+ value: 3,
27
27
  pt: {
28
28
  MALE: 'Divorciado',
29
29
  FEMALE: 'Divorciada'
@@ -34,23 +34,23 @@ export const maritalStatuses = [
34
34
  }
35
35
  },
36
36
  {
37
- value: 'WIDOW',
37
+ value: 4,
38
38
  pt: {
39
39
  MALE: 'Viúvo',
40
40
  FEMALE: 'Viúva'
41
41
  },
42
42
  en: {
43
- MALE: 'Widow',
43
+ MALE: 'Widower',
44
44
  FEMALE: 'Widow'
45
45
  }
46
46
  }
47
47
  ]
48
48
 
49
49
  export const maritalStatus = {
50
- single: 'SINGLE',
51
- married: 'MARRIED',
52
- divorced: 'DIVORCED',
53
- widow: 'WIDOW'
50
+ single: 1,
51
+ married: 2,
52
+ divorced: 3,
53
+ widow: 4
54
54
  }
55
55
 
56
- export default maritalStatuses
56
+ export default maritalStatuses
@@ -1,25 +1,31 @@
1
1
  export const marriageRegimes = [
2
2
  {
3
- value: "COMMUNITY OF PROPERTY",
3
+ value: 1,
4
4
  pt: "Comunhão de bens",
5
- en: "COMMUNITY OF PROPERTY"
5
+ en: "Community of property"
6
6
  },
7
7
  {
8
- value: "ANC-WITH ACCRUAL",
8
+ value: 2,
9
9
  pt: "Com acúmulo de bens",
10
10
  en: "ANC-WITH ACCRUAL"
11
11
  },
12
12
  {
13
- value: "ANC - WITHOUT ACCRUAL",
13
+ value: 3,
14
14
  pt: "Sem acúmulo de bens",
15
- en: "ANC-WITH ACCRUAL"
15
+ en: "ANC-WITHOUT ACCRUAL"
16
+ },
17
+ {
18
+ value: 9,
19
+ pt: "Desconhecido",
20
+ en: "Unknown"
16
21
  }
17
22
  ]
18
23
 
19
24
  export const marriageRegime = {
20
- communityProperty: "COMMUNITY OF PROPERTY",
21
- ancWithAccrual: "ANC-WITH ACCRUAL",
22
- ancwithoutAccrual: "ANC - WITHOUT ACCRUAL"
25
+ communityProperty: 1,
26
+ ancWithAccrual: 2,
27
+ ancwithoutAccrual: 3,
28
+ unknown: 9
23
29
  }
24
30
 
25
31
  export default marriageRegime
@@ -1,59 +1,59 @@
1
1
  const provinces = [
2
2
  {
3
- value: "MAPUTO CIDADE",
3
+ value: "110000",
4
4
  pt: "Maputo Cidade",
5
5
  en: "Maputo City"
6
6
  },
7
7
  {
8
- value: "MAPUTO PROVINCIA",
8
+ value: "100000",
9
9
  pt: "Maputo Província",
10
- en: "Maputo City"
10
+ en: "Maputo Province"
11
11
  },
12
12
  {
13
- value: "GAZA",
13
+ value: "90000",
14
14
  pt: "Gaza",
15
- en: "Maputo City"
15
+ en: "Gaza"
16
16
  },
17
17
  {
18
- value: "INHAMBANE",
18
+ value: "80000",
19
19
  pt: "Inhambane",
20
- en: "Maputo City"
20
+ en: "Inhambane"
21
21
  },
22
22
  {
23
- value: "SOFALA",
23
+ value: "70000",
24
24
  pt: "Sofala",
25
- en: "Maputo City"
25
+ en: "Sofala"
26
26
  },
27
27
  {
28
- value: "MANICA",
28
+ value: "60000",
29
29
  pt: "Manica",
30
- en: "Maputo City"
30
+ en: "Manica"
31
31
  },
32
32
  {
33
- value: "TETE",
33
+ value: "50000",
34
34
  pt: "Tete",
35
- en: "Maputo City"
35
+ en: "Tete"
36
36
  },
37
37
  {
38
- value: "ZAMBEZIA",
38
+ value: "40000",
39
39
  pt: "Zambézia",
40
- en: "Maputo City"
40
+ en: "Zambezia"
41
41
  },
42
42
  {
43
- value: "NAMPULA",
43
+ value: "30000",
44
44
  pt: "Nampula",
45
- en: "Maputo City"
45
+ en: "Nampula"
46
46
  },
47
47
  {
48
- value: "CABO DELGADO",
48
+ value: "20000",
49
49
  pt: "Cabo Delgado",
50
- en: "Maputo City"
50
+ en: "Cabo Delgado"
51
51
  },
52
52
  {
53
- value: "NIASSA",
53
+ value: "10000",
54
54
  pt: "Niassa",
55
- en: "Maputo City"
56
- },
55
+ en: "Niassa"
56
+ }
57
57
  ]
58
58
 
59
59
  export default provinces
@@ -3,242 +3,213 @@ const AllowedPrefixes = ['25884', '25885', '25886', '25887', '25882', '25883']
3
3
 
4
4
  // Check is a guiven email is valid
5
5
  export const isEmailValid = (email) => {
6
- if (/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i.test(email)) {
7
- return true;
8
- }
6
+ if (/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i.test(email)) {
7
+ return true;
8
+ }
9
9
  }
10
10
 
11
11
  //Check is password is strong
12
12
  export const isPasswordStrong = (password) => {
13
- if (/[a-z]/.test(password) && // checks for a-z
14
- /[0-9]/.test(password) && // checks for 0-9
15
- /\W|_/.test(password) && // checks for special char
16
- password.length >= 8 //Checks if is password 8 chars long
17
- ) {
18
- return true
19
- }
13
+ if (/[a-z]/.test(password) && // checks for a-z
14
+ /[0-9]/.test(password) && // checks for 0-9
15
+ /\W|_/.test(password) && // checks for special char
16
+ password.length >= 8 //Checks if is password 8 chars long
17
+ ) {
18
+ return true
19
+ }
20
20
  }
21
21
 
22
22
  export const isSameAs = (value1, value2) => {
23
- if (value1 === value2) {
24
- return true
25
- }
23
+ if (value1 === value2) return true
26
24
  }
27
25
 
28
26
  //Checks if string containes white space
29
27
  export const containesWhiteSpace = (string) => {
30
- string = string.replace(/(\r\n|\n|\r)/gm, " ");
31
- if (string.includes(' ')) {
32
- return true
33
- }
28
+ string = string.replace(/(\r\n|\n|\r)/gm, " ");
29
+ if (string.includes(' ')) return true
34
30
  }
35
31
 
36
-
37
32
  //Checks if value is greather then
38
33
  export const isMinValue = (minValue, value2ToCheck) => {
39
- if (minValue <= value2ToCheck) {
40
- return true
41
- }
34
+ if (minValue <= value2ToCheck) return true
42
35
  }
43
36
 
44
-
45
37
  export const isMinLength = (value, length) => {
46
- let stringValue = value.toString()
47
- stringValue = value.toLowerCase()
48
- stringValue = stringValue.split('')
49
- if (stringValue.length >= length) {
50
- return true
51
- }
38
+ let stringValue = value.toString()
39
+ stringValue = value.toLowerCase()
40
+ stringValue = stringValue.split('')
41
+ if (stringValue.length >= length) return true
52
42
  }
53
43
 
54
44
  export const isAboveMaxLength = (value, length) => {
55
- let stringValue = value.toString()
56
- stringValue = stringValue.toLowerCase()
57
- stringValue = stringValue.split('')
58
- if (stringValue.length > length) {
59
- return true
60
- }
45
+ let stringValue = value.toString()
46
+ stringValue = stringValue.toLowerCase()
47
+ stringValue = stringValue.split('')
48
+ if (stringValue.length > length) return true
61
49
  }
62
50
 
63
51
  export const isLength = (value, length) => {
64
- let stringValue = value.toString()
65
- stringValue = stringValue.toLowerCase()
66
- stringValue = stringValue.split('')
67
- if (stringValue.length === length) {
68
- return true
69
- }
52
+ let stringValue = value.toString()
53
+ stringValue = stringValue.toLowerCase()
54
+ stringValue = stringValue.split('')
55
+ if (stringValue.length === length) return true
70
56
  }
71
57
 
72
-
73
58
  export const allowedCharsOnly = (stringToTest, charSet) => {
74
- try {
75
- let stringToCheck = stringToTest.toString()
76
- const dictionary = charSet.split('')
77
-
78
- if (stringToCheck.length > 0) {
79
- let phrase = stringToCheck.toLowerCase()
80
- phrase = phrase.replace(/(\r\n|\n|\r)/gm, " ");
81
- phrase = phrase.split('');
82
- return !(phrase.some(function (item) {
83
- if(!dictionary.includes(item)){
84
- return true
59
+ try {
60
+ let stringToCheck = stringToTest.toString()
61
+ const dictionary = charSet.split('')
62
+
63
+ if (stringToCheck.length > 0) {
64
+ let phrase = stringToCheck.toLowerCase()
65
+ phrase = phrase.replace(/(\r\n|\n|\r)/gm, " ");
66
+ phrase = phrase.split('');
67
+ return !(phrase.some(function (item) {
68
+ if (!dictionary.includes(item)) {
69
+ return true
70
+ }
71
+ }
72
+ ))
85
73
  }
86
- }
87
- ))
88
- }
89
74
  } catch (e) {
90
- return false
75
+ return false
91
76
  }
92
77
  }
93
78
 
94
79
  export const startsWith = (toBeChecked, startsWithThis) => {
95
- toBeChecked = toBeChecked.toString()
96
- if (toBeChecked.startsWith(startsWithThis)) {
97
- return true
98
- }
80
+ toBeChecked = toBeChecked.toString()
81
+ if (toBeChecked.startsWith(startsWithThis)) return true
99
82
  }
100
83
 
101
84
  export const isInteger = (number) => {
102
- number = Number(number)
103
- if (Number.isInteger(number)) {
104
- return true
105
- }
85
+ number = Number(number)
86
+ if (Number.isInteger(number)) return true
106
87
  }
107
88
 
108
89
  export const isIn = (value, optionsArray) => {
109
- try {
110
- return optionsArray.includes(value)
111
- } catch (error) {
112
- return false
113
- }
90
+ try {
91
+ return optionsArray.includes(value)
92
+ } catch (error) {
93
+ return false
94
+ }
114
95
  }
115
96
 
116
-
117
97
  export const isContactValid = (number) => {
118
- if (!number) {
119
- return false
120
- } else {
121
- try {
122
- const numb = String(number)
123
- if (/^([0-9]{12})$/.test(number)) {
124
- const prefix = numb.slice(0, 5)
125
-
126
- if (isIn(prefix, AllowedPrefixes)) {
127
- return true
128
- }
98
+ if (!number) {
129
99
  return false
130
- } else {
131
- return false
132
- }
133
- } catch (e) {
134
- return false
100
+ } else {
101
+ try {
102
+ const numb = String(number)
103
+ if (/^([0-9]{12})$/.test(number)) {
104
+ const prefix = numb.slice(0, 5)
105
+
106
+ if (isIn(prefix, AllowedPrefixes)) {
107
+ return true
108
+ }
109
+ return false
110
+ } else {
111
+ return false
112
+ }
113
+ } catch (e) {
114
+ return false
115
+ }
135
116
  }
136
- }
137
117
  }
138
118
 
139
-
140
119
  export const WordsCount = (str) => {
141
- try {
142
- if (str) {
143
- str = str.replace(/(^\s*)|(\s*$)/gi, "");
144
- str = str.replace(/[ ]{2,}/gi, " ");
145
- str = str.replace(/\n /, "\n");
146
- return str.split(' ').length;
147
- } else {
148
- return 0
120
+ try {
121
+ if (str) {
122
+ str = str.replace(/(^\s*)|(\s*$)/gi, "");
123
+ str = str.replace(/[ ]{2,}/gi, " ");
124
+ str = str.replace(/\n /, "\n");
125
+ return str.split(' ').length;
126
+ } else {
127
+ return 0
128
+ }
129
+ } catch (error) {
130
+ return 0
149
131
  }
150
- } catch (error) {
151
- return 0
152
- }
153
132
  }
154
133
 
155
-
156
134
  export function isMinor(dateOfBirth, ageLimit) {
157
- let today = new Date()
158
- let birthDate = new Date(dateOfBirth)
159
- let age = today.getFullYear() - birthDate.getFullYear()
160
- let m = today.getMonth() - birthDate.getMonth()
161
- if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) {
162
- age--
163
- }
164
- if (age >= ageLimit) { return true }
135
+ let today = new Date()
136
+ let birthDate = new Date(dateOfBirth)
137
+ let age = today.getFullYear() - birthDate.getFullYear()
138
+ let m = today.getMonth() - birthDate.getMonth()
139
+ if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) {
140
+ age--
141
+ }
142
+ if (age >= ageLimit) return true
165
143
  }
166
144
 
167
-
168
- export function isBIValid (BINumber) {
169
- if (/^([0-9]{12})+([A-Z]\b)$/.test(BINumber)) {
170
- return true
171
- } else {
172
- return false
173
- }
145
+ export function isBIValid(BINumber) {
146
+ if (/^([0-9]{12})+([A-Z]\b)$/.test(BINumber)) {
147
+ return true
148
+ } else {
149
+ return false
150
+ }
174
151
  }
175
152
 
176
- export function isValidCertificateNumber(number){
177
- try {
178
- if(/^([0-9]{9})$/.test(number)){
179
- return true
153
+ export function isValidCertificateNumber(number) {
154
+ try {
155
+ if (/^([0-9]{9})$/.test(number)) return true
156
+ throw new Error()
157
+ } catch (error) {
158
+ return false
180
159
  }
181
- throw new Error()
182
- } catch (error) {
183
- return false
184
- }
185
160
  }
186
161
 
187
-
188
162
  export function isPDF(filedata) {
189
- let aux = filedata.name.split(".")
190
-
191
- const extention = aux[aux.length - 1]
192
- if (extention == "pdf" || extention == "PDF" && filedata.type == "application/pdf") {
193
- return true
194
- }
195
- return false
163
+ let aux = filedata.name.split(".")
164
+ const extention = aux[aux.length - 1]
165
+ if (extention == "pdf" || extention == "PDF" && filedata.type == "application/pdf") {
166
+ return true
167
+ }
168
+ return false
196
169
  }
197
170
 
198
-
199
-
200
171
  export function isValidNuit(nuit) {
201
- try {
202
- const nuitNumber = nuit.toString()
203
- if(nuitNumber.length != 9){
204
- return false
172
+ try {
173
+ const nuitNumber = nuit.toString()
174
+ if (nuitNumber.length != 9) {
175
+ return false
176
+ }
177
+ let a = parseInt(nuitNumber.substr(0, 1))
178
+ let b = parseInt(nuitNumber.substr(1, 1))
179
+ let c = parseInt(nuitNumber.substr(2, 1))
180
+ let d = parseInt(nuitNumber.substr(3, 1))
181
+ let e = parseInt(nuitNumber.substr(4, 1))
182
+ let f = parseInt(nuitNumber.substr(5, 1))
183
+ let g = parseInt(nuitNumber.substr(6, 1))
184
+ let h = parseInt(nuitNumber.substr(7, 1))
185
+ let checkDigit = parseInt(nuitNumber.substr(8, 1))
186
+
187
+ a = a * 3
188
+ b = b * 2
189
+ c = c * 7
190
+ d = d * 6
191
+ e = e * 5
192
+ f = f * 4
193
+ g = g * 3
194
+ h = h * 2
195
+
196
+ const digitsSum = a + b + c + d + e + f + g + h
197
+ const digitsMOD = digitsSum % 11
198
+
199
+ if (digitsMOD == 0 || digitsMOD == 1) {
200
+
201
+ if (digitsMOD == checkDigit) {
202
+ return true
203
+ }
204
+ } else {
205
+ const result = 11 - digitsMOD
206
+ if (result == checkDigit) {
207
+ return true
208
+
209
+ }
210
+ }
205
211
  }
206
- let a = parseInt(nuitNumber.substr(0, 1))
207
- let b = parseInt(nuitNumber.substr(1, 1))
208
- let c = parseInt(nuitNumber.substr(2, 1))
209
- let d = parseInt(nuitNumber.substr(3, 1))
210
- let e = parseInt(nuitNumber.substr(4, 1))
211
- let f = parseInt(nuitNumber.substr(5, 1))
212
- let g = parseInt(nuitNumber.substr(6, 1))
213
- let h = parseInt(nuitNumber.substr(7, 1))
214
- let checkDigit = parseInt(nuitNumber.substr(8, 1))
215
-
216
- a = a * 3
217
- b = b * 2
218
- c = c * 7
219
- d = d * 6
220
- e = e * 5
221
- f = f * 4
222
- g = g * 3
223
- h = h * 2
224
-
225
- const digitsSum = a + b + c + d + e + f + g + h
226
- const digitsMOD = digitsSum % 11
227
-
228
- if (digitsMOD == 0 || digitsMOD == 1) {
229
-
230
- if (digitsMOD == checkDigit) {
231
- return true
232
- }
233
- } else {
234
- const result = 11 - digitsMOD
235
- if (result == checkDigit) {
236
- return true
237
-
238
- }
212
+ catch (err) {
213
+ return false
239
214
  }
240
- }
241
- catch (err) {
242
- return false
243
- }
244
215
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stbmoz-onboarding/core",
3
3
  "type": "module",
4
- "version": "1.0.21",
4
+ "version": "1.0.23",
5
5
  "description": "\"core module\"",
6
6
  "main": "index.js",
7
7
  "scripts": {