@stbmoz-onboarding/core 1.0.12 → 1.0.13
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.
- package/Validations/index.js +16 -12
- package/package.json +1 -1
package/Validations/index.js
CHANGED
|
@@ -189,15 +189,19 @@ export function isPDF(filedata) {
|
|
|
189
189
|
export function isValidNuit(nuit) {
|
|
190
190
|
try {
|
|
191
191
|
//Split the inserted nuit
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
192
|
+
const length = nuit.toString().length
|
|
193
|
+
if(length != 9){
|
|
194
|
+
return false
|
|
195
|
+
}
|
|
196
|
+
const a = parseInt(nuit.substr(0, 1))
|
|
197
|
+
const b = parseInt(nuit.substr(1, 1))
|
|
198
|
+
const c = parseInt(nuit.substr(2, 1))
|
|
199
|
+
const d = parseInt(nuit.substr(3, 1))
|
|
200
|
+
const e = parseInt(nuit.substr(4, 1))
|
|
201
|
+
const f = parseInt(nuit.substr(5, 1))
|
|
202
|
+
const g = parseInt(nuit.substr(6, 1))
|
|
203
|
+
const h = parseInt(nuit.substr(7, 1))
|
|
204
|
+
const checkDigit = parseInt(nuit.substr(8, 1))
|
|
201
205
|
|
|
202
206
|
a = a * 3
|
|
203
207
|
b = b * 2
|
|
@@ -208,8 +212,8 @@ export function isValidNuit(nuit) {
|
|
|
208
212
|
g = g * 3
|
|
209
213
|
h = h * 2
|
|
210
214
|
|
|
211
|
-
|
|
212
|
-
|
|
215
|
+
const digitsSum = a + b + c + d + e + f + g + h
|
|
216
|
+
const digitsMOD = digitsSum % 11
|
|
213
217
|
|
|
214
218
|
if (digitsMOD == 0 || digitsMOD == 1) {
|
|
215
219
|
|
|
@@ -217,7 +221,7 @@ export function isValidNuit(nuit) {
|
|
|
217
221
|
return true
|
|
218
222
|
}
|
|
219
223
|
} else {
|
|
220
|
-
|
|
224
|
+
const result = 11 - digitsMOD
|
|
221
225
|
if (result == checkDigit) {
|
|
222
226
|
return true
|
|
223
227
|
|