x25 3.0.0 → 17.0.0
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/Account/Load.js +75 -0
- package/Account/actions.js +15 -0
- package/Account/index.js +20 -0
- package/Account/reducer.js +122 -0
- package/Account/request.js +44 -0
- package/Async/InitModule.js +190 -0
- package/Async/RouteLoading.js +64 -0
- package/Async/SimulatedException.js +44 -0
- package/Async/index.js +95 -0
- package/Async/types.js +1 -0
- package/Company/Load.js +82 -0
- package/Company/actions.js +15 -0
- package/Company/index.js +20 -0
- package/Company/reducer.js +165 -0
- package/Company/request.js +36 -0
- package/Company/util.js +10 -0
- package/Header/AccountOptionsContainer.js +144 -0
- package/Header/AdminSelectCompany.js +109 -0
- package/Header/ClientSelectCompany.js +104 -0
- package/Header/Header.js +127 -0
- package/Header/HeaderContainer.js +39 -0
- package/Header/Logo.js +30 -0
- package/Header/LogoutButton.js +39 -0
- package/Header/index.js +19 -0
- package/Header/request.js +26 -0
- package/Header/types.js +1 -0
- package/Header/util.js +58 -0
- package/Inputs/Business/BankAccount.js +48 -0
- package/Inputs/Business/BankName.js +49 -0
- package/Inputs/Business/CifField.js +112 -0
- package/Inputs/Business/CifFieldContainer.js +157 -0
- package/Inputs/Business/Email.js +37 -0
- package/Inputs/Business/NidField.js +91 -0
- package/Inputs/Business/Phone.js +37 -0
- package/Inputs/Business/index.js +34 -0
- package/Inputs/Business/request.js +39 -0
- package/Inputs/CaptchaBox.js +151 -0
- package/Inputs/DateInput.js +172 -0
- package/Inputs/DateTemplate.js +200 -0
- package/Inputs/DelayInputChange.js +135 -0
- package/Inputs/FocusTemplate.js +47 -0
- package/Inputs/InputTemplate.js +78 -0
- package/Inputs/LabelTemplate.js +59 -0
- package/Inputs/NumericInput.js +139 -0
- package/Inputs/NumericTemplate.js +148 -0
- package/Inputs/Selects/County.js +29 -0
- package/Inputs/Selects/Custom.js +56 -0
- package/Inputs/Selects/Simple.js +75 -0
- package/Inputs/Selects/index.js +52 -0
- package/Inputs/SimpleInput.js +42 -0
- package/Inputs/SimpleTextarea.js +47 -0
- package/Inputs/TextareaTemplate.js +55 -0
- package/Inputs/Tooltip.js +82 -0
- package/Inputs/index.js +185 -0
- package/Messages/Error.js +106 -0
- package/Messages/Loading.js +68 -0
- package/Messages/index.js +29 -0
- package/Modal/Delete.js +240 -0
- package/Modal/Root.js +81 -0
- package/Modal/SimpleModal.js +57 -0
- package/Modal/actions.js +10 -0
- package/Modal/getComponent.js +42 -0
- package/Modal/index.js +22 -0
- package/Modal/reducer.js +53 -0
- package/Modal/types.js +7 -0
- package/Modal/util.js +17 -0
- package/Payment/EstimatePrice/Description.js +92 -0
- package/Payment/EstimatePrice/PayBox.js +220 -0
- package/Payment/EstimatePrice/index.js +92 -0
- package/Payment/EstimatePrice/util.js +21 -0
- package/Payment/MobilpayForm.js +86 -0
- package/Payment/Modal/BankTransfer.js +233 -0
- package/Payment/Modal/CompanyValability.js +28 -0
- package/Payment/Modal/DoneForm.js +222 -0
- package/Payment/Modal/PaymentDone.js +53 -0
- package/Payment/Modal/index.js +27 -0
- package/Payment/actions.js +23 -0
- package/{src/Payment → Payment}/codes.js +19 -16
- package/Payment/index.js +141 -0
- package/Payment/request.js +49 -0
- package/Payment/types.js +1 -0
- package/Payment/util.js +50 -0
- package/Payment/validate.js +23 -0
- package/Sidebar.js +156 -0
- package/Things.js +53 -0
- package/actions.js +73 -0
- package/config.js +10 -0
- package/dev/ErrorBoundary.js +109 -0
- package/dev/TheError.js +113 -0
- package/dev/index.js +132 -0
- package/dev/types.js +1 -0
- package/package.json +13 -13
- package/prod/SentryErrorBoundary.js +150 -0
- package/reducer/captchas.js +51 -0
- package/reducer/counties.js +57 -0
- package/reducer/index.js +38 -0
- package/reducer/module.js +48 -0
- package/style/index.css +1 -0
- package/style/sidebar.css +1 -0
- package/types.js +1 -0
- package/utility/calendar.js +45 -0
- package/utility/date.js +111 -0
- package/utility/index.js +125 -0
- package/utility/language.js +20 -0
- package/utility/mql.js +6 -0
- package/utility/normalize-test.js +54 -0
- package/utility/normalize.js +108 -0
- package/utility/numbers.js +93 -0
- package/utility/numeric.js +103 -0
- package/utility/others.js +142 -0
- package/utility/strings-test.js +216 -0
- package/utility/strings.js +85 -0
- package/utility/validation/common.js +278 -0
- package/utility/validation/index.js +110 -0
- package/utility/validation/specific.js +14 -0
- package/utility/validation/validate/bank-test.js +41 -0
- package/utility/validation/validate/bank.js +176 -0
- package/utility/validation/validate/cif-test.js +37 -0
- package/utility/validation/validate/cif.js +44 -0
- package/utility/validation/validate/cnp-test.js +68 -0
- package/utility/validation/validate/cnp.js +193 -0
- package/{src/utility → utility}/validation/validate/date.js +61 -73
- package/utility/validation/validate/email-test.js +30 -0
- package/utility/validation/validate/email.js +11 -0
- package/utility/validation/validate/index.js +65 -0
- package/.eslintignore +0 -2
- package/.eslintrc.json +0 -275
- package/.flowconfig +0 -23
- package/conf/dev.js +0 -19
- package/conf/dist.js +0 -19
- package/conf/polyfills/tempPolyfills.js +0 -7
- package/src/Account/Load.jsx +0 -79
- package/src/Account/actions.js +0 -10
- package/src/Account/index.js +0 -11
- package/src/Account/reducer.js +0 -139
- package/src/Account/request.js +0 -36
- package/src/Async/InitModule.jsx +0 -114
- package/src/Async/RouteLoading.jsx +0 -52
- package/src/Async/SimulatedException.jsx +0 -19
- package/src/Async/index.jsx +0 -75
- package/src/Async/types.js +0 -39
- package/src/Company/Load.jsx +0 -84
- package/src/Company/actions.js +0 -10
- package/src/Company/index.js +0 -11
- package/src/Company/reducer.js +0 -201
- package/src/Company/request.js +0 -30
- package/src/Company/util.js +0 -7
- package/src/Header/AccountOptionsContainer.jsx +0 -124
- package/src/Header/AdminSelectCompany.jsx +0 -101
- package/src/Header/ClientSelectCompany.jsx +0 -90
- package/src/Header/Header.jsx +0 -120
- package/src/Header/HeaderContainer.jsx +0 -30
- package/src/Header/Logo.jsx +0 -16
- package/src/Header/LogoutButton.jsx +0 -34
- package/src/Header/index.jsx +0 -9
- package/src/Header/request.js +0 -28
- package/src/Header/types.js +0 -6
- package/src/Header/util.jsx +0 -61
- package/src/Inputs/Business/BankAccount.jsx +0 -39
- package/src/Inputs/Business/BankName.jsx +0 -40
- package/src/Inputs/Business/CifField.jsx +0 -93
- package/src/Inputs/Business/CifFieldContainer.jsx +0 -142
- package/src/Inputs/Business/Email.jsx +0 -23
- package/src/Inputs/Business/NidField.jsx +0 -77
- package/src/Inputs/Business/Phone.jsx +0 -23
- package/src/Inputs/Business/index.js +0 -16
- package/src/Inputs/Business/request.js +0 -39
- package/src/Inputs/CaptchaBox.jsx +0 -131
- package/src/Inputs/DateInput.jsx +0 -188
- package/src/Inputs/DateTemplate.jsx +0 -213
- package/src/Inputs/DelayInputChange.jsx +0 -130
- package/src/Inputs/FocusTemplate.jsx +0 -41
- package/src/Inputs/InputTemplate.jsx +0 -79
- package/src/Inputs/LabelTemplate.jsx +0 -47
- package/src/Inputs/NumericInput.jsx +0 -142
- package/src/Inputs/NumericTemplate.jsx +0 -155
- package/src/Inputs/Selects/County.jsx +0 -19
- package/src/Inputs/Selects/Custom.jsx +0 -55
- package/src/Inputs/Selects/Simple.jsx +0 -73
- package/src/Inputs/Selects/index.jsx +0 -37
- package/src/Inputs/SimpleInput.jsx +0 -40
- package/src/Inputs/SimpleTextarea.jsx +0 -55
- package/src/Inputs/TextareaTemplate.jsx +0 -57
- package/src/Inputs/Tooltip.jsx +0 -61
- package/src/Inputs/index.js +0 -22
- package/src/Messages/Error.jsx +0 -83
- package/src/Messages/Loading.jsx +0 -43
- package/src/Messages/index.jsx +0 -4
- package/src/Modal/Delete.jsx +0 -237
- package/src/Modal/Root.jsx +0 -57
- package/src/Modal/SimpleModal.jsx +0 -47
- package/src/Modal/actions.js +0 -7
- package/src/Modal/getComponent.jsx +0 -32
- package/src/Modal/index.jsx +0 -12
- package/src/Modal/reducer.js +0 -40
- package/src/Modal/types.js +0 -6
- package/src/Modal/util.js +0 -15
- package/src/Payment/EstimatePrice/Description.jsx +0 -101
- package/src/Payment/EstimatePrice/PayBox.jsx +0 -173
- package/src/Payment/EstimatePrice/index.jsx +0 -63
- package/src/Payment/EstimatePrice/util.js +0 -15
- package/src/Payment/MobilpayForm.jsx +0 -77
- package/src/Payment/Modal/BankTransfer.jsx +0 -129
- package/src/Payment/Modal/CompanyValability.jsx +0 -14
- package/src/Payment/Modal/DoneForm.jsx +0 -209
- package/src/Payment/Modal/PaymentDone.jsx +0 -27
- package/src/Payment/Modal/index.js +0 -13
- package/src/Payment/actions.jsx +0 -22
- package/src/Payment/index.jsx +0 -124
- package/src/Payment/request.js +0 -50
- package/src/Payment/types.js +0 -14
- package/src/Payment/util.jsx +0 -52
- package/src/Payment/validate.js +0 -25
- package/src/Sidebar.jsx +0 -158
- package/src/Things.jsx +0 -35
- package/src/actions.js +0 -36
- package/src/config.js +0 -7
- package/src/dev/ErrorBoundary.jsx +0 -98
- package/src/dev/TheError.jsx +0 -87
- package/src/dev/index.js +0 -127
- package/src/dev/types.js +0 -10
- package/src/prod/SentryErrorBoundary.jsx +0 -98
- package/src/reducer/captchas.js +0 -44
- package/src/reducer/counties.js +0 -46
- package/src/reducer/index.js +0 -25
- package/src/reducer/module.jsx +0 -43
- package/src/style/.sass-lint.yml +0 -84
- package/src/style/.stylelintrc.json +0 -161
- package/src/style/_fancy-text.scss +0 -37
- package/src/style/_fix_bootstrap_placeholder_color.scss +0 -14
- package/src/style/_header-company.scss +0 -69
- package/src/style/_inputs.scss +0 -12
- package/src/style/_minimal.scss +0 -31
- package/src/style/_navigation.scss +0 -24
- package/src/style/_others.scss +0 -79
- package/src/style/index.scss +0 -7
- package/src/style/sidebar/_animations.scss +0 -21
- package/src/style/sidebar/_dark-theme.scss +0 -77
- package/src/style/sidebar/_scroll.scss +0 -37
- package/src/style/sidebar/_structure.scss +0 -299
- package/src/style/sidebar.scss +0 -4
- package/src/types.js +0 -31
- package/src/utility/calendar.js +0 -39
- package/src/utility/date.js +0 -100
- package/src/utility/index.js +0 -12
- package/src/utility/language.js +0 -17
- package/src/utility/mql.js +0 -3
- package/src/utility/normalize-test.js +0 -58
- package/src/utility/normalize.js +0 -119
- package/src/utility/numbers.js +0 -87
- package/src/utility/numeric.js +0 -114
- package/src/utility/others.jsx +0 -160
- package/src/utility/strings-test.js +0 -136
- package/src/utility/strings.js +0 -80
- package/src/utility/validation/common.js +0 -360
- package/src/utility/validation/index.js +0 -70
- package/src/utility/validation/specific.js +0 -9
- package/src/utility/validation/validate/bank-test.js +0 -129
- package/src/utility/validation/validate/bank.js +0 -176
- package/src/utility/validation/validate/cif-test.js +0 -105
- package/src/utility/validation/validate/cif.js +0 -44
- package/src/utility/validation/validate/cnp-test.js +0 -216
- package/src/utility/validation/validate/cnp.js +0 -261
- package/src/utility/validation/validate/email-test.js +0 -36
- package/src/utility/validation/validate/email.js +0 -6
- package/src/utility/validation/validate/index.js +0 -7
- package/webpack.config.js +0 -90
- package/x25.wiki/Account.md +0 -41
- package/x25.wiki/Company.md +0 -39
- package/x25.wiki/Header.md +0 -21
- package/x25.wiki/Home.md +0 -1
- package/x25.wiki/Inputs.md +0 -33
- package/x25.wiki/Messages.md +0 -27
- package/x25.wiki/Payment.md +0 -42
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
export const isValidBankAccount = (rawValue : string) : boolean => {
|
|
4
|
-
|
|
5
|
-
// Remove spaces and to upper case
|
|
6
|
-
const checkPosition = 4,
|
|
7
|
-
iban = rawValue.replace(/ /gu,
|
|
8
|
-
"").toUpperCase(),
|
|
9
|
-
hasGoodCountryCode = () : boolean => {
|
|
10
|
-
|
|
11
|
-
if (iban.length <= 2) {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const countrycode = iban.substring(0,
|
|
16
|
-
2),
|
|
17
|
-
bbancountrypatterns = {
|
|
18
|
-
"AD" : "\\d{8}[\\dA-Z]{12}",
|
|
19
|
-
"AE" : "\\d{3}\\d{16}",
|
|
20
|
-
"AL" : "\\d{8}[\\dA-Z]{16}",
|
|
21
|
-
"AT" : "\\d{16}",
|
|
22
|
-
"AZ" : "[\\dA-Z]{4}\\d{20}",
|
|
23
|
-
"BA" : "\\d{16}",
|
|
24
|
-
"BE" : "\\d{12}",
|
|
25
|
-
"BG" : "[A-Z]{4}\\d{6}[\\dA-Z]{8}",
|
|
26
|
-
"BH" : "[A-Z]{4}[\\dA-Z]{14}",
|
|
27
|
-
"BR" : "\\d{23}[A-Z][\\dA-Z]",
|
|
28
|
-
"CH" : "\\d{5}[\\dA-Z]{12}",
|
|
29
|
-
"CR" : "\\d{17}",
|
|
30
|
-
"CY" : "\\d{8}[\\dA-Z]{16}",
|
|
31
|
-
"CZ" : "\\d{20}",
|
|
32
|
-
"DE" : "\\d{18}",
|
|
33
|
-
"DK" : "\\d{14}",
|
|
34
|
-
"DO" : "[A-Z]{4}\\d{20}",
|
|
35
|
-
"EE" : "\\d{16}",
|
|
36
|
-
"ES" : "\\d{20}",
|
|
37
|
-
"FI" : "\\d{14}",
|
|
38
|
-
"FO" : "\\d{14}",
|
|
39
|
-
"FR" : "\\d{10}[\\dA-Z]{11}\\d{2}",
|
|
40
|
-
"GB" : "[A-Z]{4}\\d{14}",
|
|
41
|
-
"GE" : "[\\dA-Z]{2}\\d{16}",
|
|
42
|
-
"GI" : "[A-Z]{4}[\\dA-Z]{15}",
|
|
43
|
-
"GL" : "\\d{14}",
|
|
44
|
-
"GR" : "\\d{7}[\\dA-Z]{16}",
|
|
45
|
-
"GT" : "[\\dA-Z]{4}[\\dA-Z]{20}",
|
|
46
|
-
"HR" : "\\d{17}",
|
|
47
|
-
"HU" : "\\d{24}",
|
|
48
|
-
"IE" : "[\\dA-Z]{4}\\d{14}",
|
|
49
|
-
"IL" : "\\d{19}",
|
|
50
|
-
"IS" : "\\d{22}",
|
|
51
|
-
"IT" : "[A-Z]\\d{10}[\\dA-Z]{12}",
|
|
52
|
-
"KW" : "[A-Z]{4}[\\dA-Z]{22}",
|
|
53
|
-
"KZ" : "\\d{3}[\\dA-Z]{13}",
|
|
54
|
-
"LB" : "\\d{4}[\\dA-Z]{20}",
|
|
55
|
-
"LI" : "\\d{5}[\\dA-Z]{12}",
|
|
56
|
-
"LT" : "\\d{16}",
|
|
57
|
-
"LU" : "\\d{3}[\\dA-Z]{13}",
|
|
58
|
-
"LV" : "[A-Z]{4}[\\dA-Z]{13}",
|
|
59
|
-
"MC" : "\\d{10}[\\dA-Z]{11}\\d{2}",
|
|
60
|
-
"MD" : "[\\dA-Z]{2}\\d{18}",
|
|
61
|
-
"ME" : "\\d{18}",
|
|
62
|
-
"MK" : "\\d{3}[\\dA-Z]{10}\\d{2}",
|
|
63
|
-
"MR" : "\\d{23}",
|
|
64
|
-
"MT" : "[A-Z]{4}\\d{5}[\\dA-Z]{18}",
|
|
65
|
-
"MU" : "[A-Z]{4}\\d{19}[A-Z]{3}",
|
|
66
|
-
"NL" : "[A-Z]{4}\\d{10}",
|
|
67
|
-
"NO" : "\\d{11}",
|
|
68
|
-
"PK" : "[\\dA-Z]{4}\\d{16}",
|
|
69
|
-
"PL" : "\\d{24}",
|
|
70
|
-
"PS" : "[\\dA-Z]{4}\\d{21}",
|
|
71
|
-
"PT" : "\\d{21}",
|
|
72
|
-
"RO" : "[A-Z]{4}[\\dA-Z]{16}",
|
|
73
|
-
"RS" : "\\d{18}",
|
|
74
|
-
"SA" : "\\d{2}[\\dA-Z]{18}",
|
|
75
|
-
"SE" : "\\d{20}",
|
|
76
|
-
"SI" : "\\d{15}",
|
|
77
|
-
"SK" : "\\d{20}",
|
|
78
|
-
"SM" : "[A-Z]\\d{10}[\\dA-Z]{12}",
|
|
79
|
-
"TN" : "\\d{20}",
|
|
80
|
-
"TR" : "\\d{5}[\\dA-Z]{17}",
|
|
81
|
-
"VG" : "[\\dA-Z]{4}\\d{16}",
|
|
82
|
-
},
|
|
83
|
-
bbanpattern = bbancountrypatterns[countrycode];
|
|
84
|
-
|
|
85
|
-
/*
|
|
86
|
-
* As new countries will start using IBAN in the
|
|
87
|
-
* future, we only check if the countrycode is known.
|
|
88
|
-
* This prevents false negatives, while almost all
|
|
89
|
-
* false positives introduced by this, will be caught
|
|
90
|
-
* by the checksum validation below anyway.
|
|
91
|
-
* Strict checking should return FALSE for unknown
|
|
92
|
-
* countries.
|
|
93
|
-
*/
|
|
94
|
-
if (typeof bbanpattern === "undefined") {
|
|
95
|
-
return false;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
const ibanregexp = new RegExp(`^[A-Z]{2}\\d{2}${bbanpattern}$`,
|
|
99
|
-
"u");
|
|
100
|
-
|
|
101
|
-
// Invalid country specific format
|
|
102
|
-
return ibanregexp.test(iban);
|
|
103
|
-
},
|
|
104
|
-
hasGoodRest = () : boolean => {
|
|
105
|
-
const getCheckDigits = () => {
|
|
106
|
-
|
|
107
|
-
const getCheck = () : string => {
|
|
108
|
-
const first = String(iban.substring(checkPosition,
|
|
109
|
-
iban.length)),
|
|
110
|
-
second = String(iban.substring(0,
|
|
111
|
-
checkPosition));
|
|
112
|
-
|
|
113
|
-
return first + second;
|
|
114
|
-
},
|
|
115
|
-
ibancheck = getCheck();
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
let leadingZeroes = true,
|
|
119
|
-
value = "";
|
|
120
|
-
|
|
121
|
-
for (let index = 0; index < ibancheck.length; index += 1) {
|
|
122
|
-
const character = ibancheck.charAt(index);
|
|
123
|
-
|
|
124
|
-
if (character !== "0") {
|
|
125
|
-
leadingZeroes = false;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
if (!leadingZeroes) {
|
|
129
|
-
value += "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".indexOf(character);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
return value;
|
|
134
|
-
},
|
|
135
|
-
ibancheckdigits = getCheckDigits(),
|
|
136
|
-
nrToDevide = 97,
|
|
137
|
-
getOperator = ({ cRest, cChar } : { cRest: number, cChar : string}) => {
|
|
138
|
-
const rest = (cRest === 0) ? "" : String(cRest);
|
|
139
|
-
|
|
140
|
-
return Number(`${rest}${cChar}`);
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
let currentRest = 0;
|
|
144
|
-
|
|
145
|
-
for (let index = 0; index < ibancheckdigits.length; index += 1) {
|
|
146
|
-
const cChar = ibancheckdigits.charAt(index),
|
|
147
|
-
cOperator = getOperator({
|
|
148
|
-
cRest: currentRest,
|
|
149
|
-
cChar,
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
if (cOperator === "" || isNaN(cOperator)) {
|
|
153
|
-
return false;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
currentRest = cOperator % nrToDevide;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
return currentRest === 1;
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
// 1. Check the country code and find the country specific format
|
|
163
|
-
|
|
164
|
-
if (!hasGoodCountryCode()) {
|
|
165
|
-
|
|
166
|
-
return false;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
// 2. Check the checksum{
|
|
170
|
-
if (!hasGoodRest()) {
|
|
171
|
-
|
|
172
|
-
return false;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
return true;
|
|
176
|
-
};
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { isValidCIF } from "./cif";
|
|
2
|
-
|
|
3
|
-
const valid = true,
|
|
4
|
-
notValid = false;
|
|
5
|
-
|
|
6
|
-
const wrong = [
|
|
7
|
-
|
|
8
|
-
"adsasd",
|
|
9
|
-
|
|
10
|
-
// too short < 6
|
|
11
|
-
"00",
|
|
12
|
-
|
|
13
|
-
// too long > 10
|
|
14
|
-
"00000000001",
|
|
15
|
-
|
|
16
|
-
// contains other things
|
|
17
|
-
"aaaaaaaaaa",
|
|
18
|
-
|
|
19
|
-
"1450123",
|
|
20
|
-
|
|
21
|
-
"13880060",
|
|
22
|
-
"13880061",
|
|
23
|
-
"13880062",
|
|
24
|
-
// "51584214", // <-- this is good
|
|
25
|
-
"13880064",
|
|
26
|
-
"13880065",
|
|
27
|
-
"13880066",
|
|
28
|
-
"13880067",
|
|
29
|
-
"13880068",
|
|
30
|
-
"13880069",
|
|
31
|
-
];
|
|
32
|
-
|
|
33
|
-
wrong.map((cif) => (
|
|
34
|
-
describe(`given the wrong CIF ${cif}`,
|
|
35
|
-
() => {
|
|
36
|
-
it("should not be valid",
|
|
37
|
-
() => {
|
|
38
|
-
expect(isValidCIF(cif)).toBe(notValid);
|
|
39
|
-
});
|
|
40
|
-
})
|
|
41
|
-
));
|
|
42
|
-
|
|
43
|
-
const good = [
|
|
44
|
-
|
|
45
|
-
"4446651",
|
|
46
|
-
"3678190",
|
|
47
|
-
"4352719",
|
|
48
|
-
"3627676",
|
|
49
|
-
"7525881",
|
|
50
|
-
"4347666",
|
|
51
|
-
"3372840",
|
|
52
|
-
"5217524",
|
|
53
|
-
"4317819",
|
|
54
|
-
"4192600",
|
|
55
|
-
"4266928",
|
|
56
|
-
"4233815",
|
|
57
|
-
"4288004",
|
|
58
|
-
"4300787",
|
|
59
|
-
"4300574",
|
|
60
|
-
"4332134",
|
|
61
|
-
"3519380",
|
|
62
|
-
"4375178",
|
|
63
|
-
"4297924",
|
|
64
|
-
"3127336",
|
|
65
|
-
"11078781",
|
|
66
|
-
"3897033",
|
|
67
|
-
"4541874",
|
|
68
|
-
"4605609",
|
|
69
|
-
"4245518",
|
|
70
|
-
"4358002",
|
|
71
|
-
"4230436",
|
|
72
|
-
"4266898",
|
|
73
|
-
"2613486",
|
|
74
|
-
"4318113",
|
|
75
|
-
"2844154",
|
|
76
|
-
"4222310",
|
|
77
|
-
"2540830",
|
|
78
|
-
"4287378",
|
|
79
|
-
"3897343",
|
|
80
|
-
"4540062",
|
|
81
|
-
"5397247",
|
|
82
|
-
"4556140",
|
|
83
|
-
"4231881",
|
|
84
|
-
"4244393",
|
|
85
|
-
"4280213",
|
|
86
|
-
"4323179",
|
|
87
|
-
"4567890",
|
|
88
|
-
"6412248",
|
|
89
|
-
"4269304",
|
|
90
|
-
"4321658",
|
|
91
|
-
"4494721",
|
|
92
|
-
"4404613",
|
|
93
|
-
|
|
94
|
-
"51584214",
|
|
95
|
-
];
|
|
96
|
-
|
|
97
|
-
good.map((cif) => (
|
|
98
|
-
describe(`given the good CIF ${cif}`,
|
|
99
|
-
() => {
|
|
100
|
-
it("should be valid",
|
|
101
|
-
() => {
|
|
102
|
-
expect(isValidCIF(cif)).toBe(valid);
|
|
103
|
-
});
|
|
104
|
-
})
|
|
105
|
-
));
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
export const isValidCIF = (rawValue : string) : boolean => {
|
|
4
|
-
const len = rawValue.length,
|
|
5
|
-
value = Number(rawValue),
|
|
6
|
-
ten = 10,
|
|
7
|
-
eleven = 11,
|
|
8
|
-
controlDigit1 = value % ten,
|
|
9
|
-
upperLimit = 10,
|
|
10
|
-
lowerLimit = 4,
|
|
11
|
-
getControlDigit2 = () : number => {
|
|
12
|
-
let controlNumber = 753217532,
|
|
13
|
-
controlDigit2 = 0,
|
|
14
|
-
current = parseInt(value / ten,
|
|
15
|
-
ten),
|
|
16
|
-
accumulator = 0;
|
|
17
|
-
|
|
18
|
-
while (current > 0) {
|
|
19
|
-
const controlDigit = (controlNumber % ten);
|
|
20
|
-
|
|
21
|
-
accumulator += (current % ten) * controlDigit;
|
|
22
|
-
|
|
23
|
-
current = parseInt(current / ten,
|
|
24
|
-
ten);
|
|
25
|
-
controlNumber = parseInt(controlNumber / ten,
|
|
26
|
-
ten);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
controlDigit2 = accumulator * ten % eleven;
|
|
30
|
-
|
|
31
|
-
if (controlDigit2 === ten) {
|
|
32
|
-
controlDigit2 = 0;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return controlDigit2;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
if (isNaN(value) || len > upperLimit || len < lowerLimit) {
|
|
39
|
-
// console.warn("The length must be between 6 and 10 digits");
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return controlDigit1 === getControlDigit2();
|
|
44
|
-
};
|
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
import { isValidCNP } from "./cnp";
|
|
2
|
-
|
|
3
|
-
const valid = true,
|
|
4
|
-
notValid = false;
|
|
5
|
-
|
|
6
|
-
const wrongCNPs = [
|
|
7
|
-
|
|
8
|
-
// less than 13 characters
|
|
9
|
-
"000",
|
|
10
|
-
|
|
11
|
-
// more than 13 characters
|
|
12
|
-
"00000000000000",
|
|
13
|
-
|
|
14
|
-
// not all digits
|
|
15
|
-
" ",
|
|
16
|
-
"a234567890123",
|
|
17
|
-
"1x34567890123",
|
|
18
|
-
"12y4567890123",
|
|
19
|
-
"123(567890123",
|
|
20
|
-
"1234*67890123",
|
|
21
|
-
"12345-7890123",
|
|
22
|
-
"123456+890123",
|
|
23
|
-
"1234567`90123",
|
|
24
|
-
"12345678!0123",
|
|
25
|
-
"123456789@123",
|
|
26
|
-
"12345678901&3",
|
|
27
|
-
"123456789012=",
|
|
28
|
-
|
|
29
|
-
// Digit 1 not 0
|
|
30
|
-
"0000000000000",
|
|
31
|
-
|
|
32
|
-
/*
|
|
33
|
-
* Wrong month
|
|
34
|
-
* Too small
|
|
35
|
-
*/
|
|
36
|
-
"1230000000000",
|
|
37
|
-
// Too big
|
|
38
|
-
"1231300000000",
|
|
39
|
-
"1234500000000",
|
|
40
|
-
"1239900000000",
|
|
41
|
-
|
|
42
|
-
// Wrong date
|
|
43
|
-
"1000100000000",
|
|
44
|
-
"1000100000000",
|
|
45
|
-
"1231200000000",
|
|
46
|
-
"3431250000000",
|
|
47
|
-
"8430100000000",
|
|
48
|
-
"6431132000000",
|
|
49
|
-
"5160230000000",
|
|
50
|
-
|
|
51
|
-
/*
|
|
52
|
-
* Wrong County
|
|
53
|
-
* 0
|
|
54
|
-
*/
|
|
55
|
-
"1930426000000",
|
|
56
|
-
|
|
57
|
-
// Too big
|
|
58
|
-
"1930426530000",
|
|
59
|
-
"1930426990000",
|
|
60
|
-
|
|
61
|
-
// Number - allowed only 001 --> 999
|
|
62
|
-
"1930426010000",
|
|
63
|
-
|
|
64
|
-
// Check controll all posible conbinations
|
|
65
|
-
"1930426450030",
|
|
66
|
-
"1930426450031",
|
|
67
|
-
"1930426450032",
|
|
68
|
-
"1930426450033",
|
|
69
|
-
"1930426450034",
|
|
70
|
-
// "1930426450035", // --> this is good
|
|
71
|
-
"1930426450036",
|
|
72
|
-
"1930426450037",
|
|
73
|
-
"1930426450038",
|
|
74
|
-
"1930426450039",
|
|
75
|
-
|
|
76
|
-
"1730513635451",
|
|
77
|
-
];
|
|
78
|
-
|
|
79
|
-
wrongCNPs.map((cnp) => (
|
|
80
|
-
describe(`given the wrong CNP ${cnp}`,
|
|
81
|
-
() => {
|
|
82
|
-
it("should not be valid",
|
|
83
|
-
() => {
|
|
84
|
-
expect(isValidCNP(cnp)).toBe(notValid);
|
|
85
|
-
});
|
|
86
|
-
})
|
|
87
|
-
));
|
|
88
|
-
|
|
89
|
-
const goodCNPs = [
|
|
90
|
-
|
|
91
|
-
"1601224522490",
|
|
92
|
-
// list from http://cnp-orange-young.blogspot.ro/
|
|
93
|
-
"1851021345131",
|
|
94
|
-
"1920617149053",
|
|
95
|
-
"1870505168646",
|
|
96
|
-
"1870619152998",
|
|
97
|
-
"1921204325416",
|
|
98
|
-
"1931011351347",
|
|
99
|
-
"1860601214764",
|
|
100
|
-
"1930114152084",
|
|
101
|
-
"1930729213031",
|
|
102
|
-
"1931110257176",
|
|
103
|
-
"1900806182888",
|
|
104
|
-
"1920201181713",
|
|
105
|
-
"1911202393786",
|
|
106
|
-
"1860114313017",
|
|
107
|
-
"1900129321797",
|
|
108
|
-
"1910319357474",
|
|
109
|
-
"1881110136241",
|
|
110
|
-
"1910313389932",
|
|
111
|
-
"1930324128027",
|
|
112
|
-
"1860713267955",
|
|
113
|
-
"1920110059921",
|
|
114
|
-
"1920323137670",
|
|
115
|
-
"1910524257786",
|
|
116
|
-
"1910219353588",
|
|
117
|
-
"1921113049026",
|
|
118
|
-
"1910510171180",
|
|
119
|
-
"1921219189118",
|
|
120
|
-
"1930614296921",
|
|
121
|
-
"1930408137659",
|
|
122
|
-
"1860525171600",
|
|
123
|
-
"1871008113318",
|
|
124
|
-
"1900809164551",
|
|
125
|
-
"1870418305339",
|
|
126
|
-
"1920622093590",
|
|
127
|
-
"1860228422041",
|
|
128
|
-
"1881024199710",
|
|
129
|
-
"1901119289825",
|
|
130
|
-
"1870623151354",
|
|
131
|
-
"1880717053385",
|
|
132
|
-
"1860331281263",
|
|
133
|
-
"1921127239892",
|
|
134
|
-
"1860726084246",
|
|
135
|
-
"1891209392109",
|
|
136
|
-
"1870610429939",
|
|
137
|
-
"1891101155151",
|
|
138
|
-
"1900515188610",
|
|
139
|
-
"1900817347850",
|
|
140
|
-
"1850603113108",
|
|
141
|
-
"1920219031621",
|
|
142
|
-
"1880716319353",
|
|
143
|
-
"1851123072213",
|
|
144
|
-
"1890503074079",
|
|
145
|
-
"1920929194685",
|
|
146
|
-
"1930604396824",
|
|
147
|
-
"1920721211943",
|
|
148
|
-
"1911125017410",
|
|
149
|
-
"1920328331453",
|
|
150
|
-
"1891012055602",
|
|
151
|
-
"1850412422567",
|
|
152
|
-
"1900830012030",
|
|
153
|
-
"1901109372453",
|
|
154
|
-
"1901119063169",
|
|
155
|
-
"1910801238953",
|
|
156
|
-
"1850126336642",
|
|
157
|
-
"1870619334654",
|
|
158
|
-
"1880930146221",
|
|
159
|
-
"1861019351849",
|
|
160
|
-
"1930502103999",
|
|
161
|
-
"1930425361934",
|
|
162
|
-
"1871108269030",
|
|
163
|
-
"1860622273209",
|
|
164
|
-
"1920723362204",
|
|
165
|
-
"1880919016077",
|
|
166
|
-
"1860627124609",
|
|
167
|
-
"1930210191367",
|
|
168
|
-
"1920306379899",
|
|
169
|
-
"1860621221169",
|
|
170
|
-
"1890514289320",
|
|
171
|
-
"1920421395061",
|
|
172
|
-
"1930426272907",
|
|
173
|
-
"1861224076805",
|
|
174
|
-
"1850204207530",
|
|
175
|
-
"1930726241832",
|
|
176
|
-
"1920229184105",
|
|
177
|
-
"1910318245177",
|
|
178
|
-
"1871225154992",
|
|
179
|
-
"1890425099446",
|
|
180
|
-
|
|
181
|
-
"1920918187490",
|
|
182
|
-
"1911017023863",
|
|
183
|
-
"1900514401426",
|
|
184
|
-
"1860117328230",
|
|
185
|
-
"1861019339785",
|
|
186
|
-
"1870119334824",
|
|
187
|
-
"1880316079025",
|
|
188
|
-
"1910216018631",
|
|
189
|
-
"1920425405811",
|
|
190
|
-
"1920904145205",
|
|
191
|
-
"1881201016278",
|
|
192
|
-
"1920731125084",
|
|
193
|
-
"1901003395568",
|
|
194
|
-
|
|
195
|
-
"1590512521591",
|
|
196
|
-
"1660418230010",
|
|
197
|
-
"1891119450065",
|
|
198
|
-
"1920310430037",
|
|
199
|
-
"1920504521696",
|
|
200
|
-
"1930426450035",
|
|
201
|
-
"2770926521590",
|
|
202
|
-
"2830111410090",
|
|
203
|
-
"2880330521699",
|
|
204
|
-
"2900117521690",
|
|
205
|
-
"2910825522143",
|
|
206
|
-
];
|
|
207
|
-
|
|
208
|
-
goodCNPs.map((cnp) => (
|
|
209
|
-
describe(`given the good CNP ${cnp}`,
|
|
210
|
-
() => {
|
|
211
|
-
it("should be valid",
|
|
212
|
-
() => {
|
|
213
|
-
expect(isValidCNP(cnp)).toBe(valid);
|
|
214
|
-
});
|
|
215
|
-
})
|
|
216
|
-
));
|