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.
Files changed (274) hide show
  1. package/Account/Load.js +75 -0
  2. package/Account/actions.js +15 -0
  3. package/Account/index.js +20 -0
  4. package/Account/reducer.js +122 -0
  5. package/Account/request.js +44 -0
  6. package/Async/InitModule.js +190 -0
  7. package/Async/RouteLoading.js +64 -0
  8. package/Async/SimulatedException.js +44 -0
  9. package/Async/index.js +95 -0
  10. package/Async/types.js +1 -0
  11. package/Company/Load.js +82 -0
  12. package/Company/actions.js +15 -0
  13. package/Company/index.js +20 -0
  14. package/Company/reducer.js +165 -0
  15. package/Company/request.js +36 -0
  16. package/Company/util.js +10 -0
  17. package/Header/AccountOptionsContainer.js +144 -0
  18. package/Header/AdminSelectCompany.js +109 -0
  19. package/Header/ClientSelectCompany.js +104 -0
  20. package/Header/Header.js +127 -0
  21. package/Header/HeaderContainer.js +39 -0
  22. package/Header/Logo.js +30 -0
  23. package/Header/LogoutButton.js +39 -0
  24. package/Header/index.js +19 -0
  25. package/Header/request.js +26 -0
  26. package/Header/types.js +1 -0
  27. package/Header/util.js +58 -0
  28. package/Inputs/Business/BankAccount.js +48 -0
  29. package/Inputs/Business/BankName.js +49 -0
  30. package/Inputs/Business/CifField.js +112 -0
  31. package/Inputs/Business/CifFieldContainer.js +157 -0
  32. package/Inputs/Business/Email.js +37 -0
  33. package/Inputs/Business/NidField.js +91 -0
  34. package/Inputs/Business/Phone.js +37 -0
  35. package/Inputs/Business/index.js +34 -0
  36. package/Inputs/Business/request.js +39 -0
  37. package/Inputs/CaptchaBox.js +151 -0
  38. package/Inputs/DateInput.js +172 -0
  39. package/Inputs/DateTemplate.js +200 -0
  40. package/Inputs/DelayInputChange.js +135 -0
  41. package/Inputs/FocusTemplate.js +47 -0
  42. package/Inputs/InputTemplate.js +78 -0
  43. package/Inputs/LabelTemplate.js +59 -0
  44. package/Inputs/NumericInput.js +139 -0
  45. package/Inputs/NumericTemplate.js +148 -0
  46. package/Inputs/Selects/County.js +29 -0
  47. package/Inputs/Selects/Custom.js +56 -0
  48. package/Inputs/Selects/Simple.js +75 -0
  49. package/Inputs/Selects/index.js +52 -0
  50. package/Inputs/SimpleInput.js +42 -0
  51. package/Inputs/SimpleTextarea.js +47 -0
  52. package/Inputs/TextareaTemplate.js +55 -0
  53. package/Inputs/Tooltip.js +82 -0
  54. package/Inputs/index.js +185 -0
  55. package/Messages/Error.js +106 -0
  56. package/Messages/Loading.js +68 -0
  57. package/Messages/index.js +29 -0
  58. package/Modal/Delete.js +240 -0
  59. package/Modal/Root.js +81 -0
  60. package/Modal/SimpleModal.js +57 -0
  61. package/Modal/actions.js +10 -0
  62. package/Modal/getComponent.js +42 -0
  63. package/Modal/index.js +22 -0
  64. package/Modal/reducer.js +53 -0
  65. package/Modal/types.js +7 -0
  66. package/Modal/util.js +17 -0
  67. package/Payment/EstimatePrice/Description.js +92 -0
  68. package/Payment/EstimatePrice/PayBox.js +220 -0
  69. package/Payment/EstimatePrice/index.js +92 -0
  70. package/Payment/EstimatePrice/util.js +21 -0
  71. package/Payment/MobilpayForm.js +86 -0
  72. package/Payment/Modal/BankTransfer.js +233 -0
  73. package/Payment/Modal/CompanyValability.js +28 -0
  74. package/Payment/Modal/DoneForm.js +222 -0
  75. package/Payment/Modal/PaymentDone.js +53 -0
  76. package/Payment/Modal/index.js +27 -0
  77. package/Payment/actions.js +23 -0
  78. package/{src/Payment → Payment}/codes.js +19 -16
  79. package/Payment/index.js +141 -0
  80. package/Payment/request.js +49 -0
  81. package/Payment/types.js +1 -0
  82. package/Payment/util.js +50 -0
  83. package/Payment/validate.js +23 -0
  84. package/Sidebar.js +156 -0
  85. package/Things.js +53 -0
  86. package/actions.js +73 -0
  87. package/config.js +10 -0
  88. package/dev/ErrorBoundary.js +109 -0
  89. package/dev/TheError.js +113 -0
  90. package/dev/index.js +132 -0
  91. package/dev/types.js +1 -0
  92. package/package.json +13 -13
  93. package/prod/SentryErrorBoundary.js +150 -0
  94. package/reducer/captchas.js +51 -0
  95. package/reducer/counties.js +57 -0
  96. package/reducer/index.js +38 -0
  97. package/reducer/module.js +48 -0
  98. package/style/index.css +1 -0
  99. package/style/sidebar.css +1 -0
  100. package/types.js +1 -0
  101. package/utility/calendar.js +45 -0
  102. package/utility/date.js +111 -0
  103. package/utility/index.js +125 -0
  104. package/utility/language.js +20 -0
  105. package/utility/mql.js +6 -0
  106. package/utility/normalize-test.js +54 -0
  107. package/utility/normalize.js +108 -0
  108. package/utility/numbers.js +93 -0
  109. package/utility/numeric.js +103 -0
  110. package/utility/others.js +142 -0
  111. package/utility/strings-test.js +216 -0
  112. package/utility/strings.js +85 -0
  113. package/utility/validation/common.js +278 -0
  114. package/utility/validation/index.js +110 -0
  115. package/utility/validation/specific.js +14 -0
  116. package/utility/validation/validate/bank-test.js +41 -0
  117. package/utility/validation/validate/bank.js +176 -0
  118. package/utility/validation/validate/cif-test.js +37 -0
  119. package/utility/validation/validate/cif.js +44 -0
  120. package/utility/validation/validate/cnp-test.js +68 -0
  121. package/utility/validation/validate/cnp.js +193 -0
  122. package/{src/utility → utility}/validation/validate/date.js +61 -73
  123. package/utility/validation/validate/email-test.js +30 -0
  124. package/utility/validation/validate/email.js +11 -0
  125. package/utility/validation/validate/index.js +65 -0
  126. package/.eslintignore +0 -2
  127. package/.eslintrc.json +0 -275
  128. package/.flowconfig +0 -23
  129. package/conf/dev.js +0 -19
  130. package/conf/dist.js +0 -19
  131. package/conf/polyfills/tempPolyfills.js +0 -7
  132. package/src/Account/Load.jsx +0 -79
  133. package/src/Account/actions.js +0 -10
  134. package/src/Account/index.js +0 -11
  135. package/src/Account/reducer.js +0 -139
  136. package/src/Account/request.js +0 -36
  137. package/src/Async/InitModule.jsx +0 -114
  138. package/src/Async/RouteLoading.jsx +0 -52
  139. package/src/Async/SimulatedException.jsx +0 -19
  140. package/src/Async/index.jsx +0 -75
  141. package/src/Async/types.js +0 -39
  142. package/src/Company/Load.jsx +0 -84
  143. package/src/Company/actions.js +0 -10
  144. package/src/Company/index.js +0 -11
  145. package/src/Company/reducer.js +0 -201
  146. package/src/Company/request.js +0 -30
  147. package/src/Company/util.js +0 -7
  148. package/src/Header/AccountOptionsContainer.jsx +0 -124
  149. package/src/Header/AdminSelectCompany.jsx +0 -101
  150. package/src/Header/ClientSelectCompany.jsx +0 -90
  151. package/src/Header/Header.jsx +0 -120
  152. package/src/Header/HeaderContainer.jsx +0 -30
  153. package/src/Header/Logo.jsx +0 -16
  154. package/src/Header/LogoutButton.jsx +0 -34
  155. package/src/Header/index.jsx +0 -9
  156. package/src/Header/request.js +0 -28
  157. package/src/Header/types.js +0 -6
  158. package/src/Header/util.jsx +0 -61
  159. package/src/Inputs/Business/BankAccount.jsx +0 -39
  160. package/src/Inputs/Business/BankName.jsx +0 -40
  161. package/src/Inputs/Business/CifField.jsx +0 -93
  162. package/src/Inputs/Business/CifFieldContainer.jsx +0 -142
  163. package/src/Inputs/Business/Email.jsx +0 -23
  164. package/src/Inputs/Business/NidField.jsx +0 -77
  165. package/src/Inputs/Business/Phone.jsx +0 -23
  166. package/src/Inputs/Business/index.js +0 -16
  167. package/src/Inputs/Business/request.js +0 -39
  168. package/src/Inputs/CaptchaBox.jsx +0 -131
  169. package/src/Inputs/DateInput.jsx +0 -188
  170. package/src/Inputs/DateTemplate.jsx +0 -213
  171. package/src/Inputs/DelayInputChange.jsx +0 -130
  172. package/src/Inputs/FocusTemplate.jsx +0 -41
  173. package/src/Inputs/InputTemplate.jsx +0 -79
  174. package/src/Inputs/LabelTemplate.jsx +0 -47
  175. package/src/Inputs/NumericInput.jsx +0 -142
  176. package/src/Inputs/NumericTemplate.jsx +0 -155
  177. package/src/Inputs/Selects/County.jsx +0 -19
  178. package/src/Inputs/Selects/Custom.jsx +0 -55
  179. package/src/Inputs/Selects/Simple.jsx +0 -73
  180. package/src/Inputs/Selects/index.jsx +0 -37
  181. package/src/Inputs/SimpleInput.jsx +0 -40
  182. package/src/Inputs/SimpleTextarea.jsx +0 -55
  183. package/src/Inputs/TextareaTemplate.jsx +0 -57
  184. package/src/Inputs/Tooltip.jsx +0 -61
  185. package/src/Inputs/index.js +0 -22
  186. package/src/Messages/Error.jsx +0 -83
  187. package/src/Messages/Loading.jsx +0 -43
  188. package/src/Messages/index.jsx +0 -4
  189. package/src/Modal/Delete.jsx +0 -237
  190. package/src/Modal/Root.jsx +0 -57
  191. package/src/Modal/SimpleModal.jsx +0 -47
  192. package/src/Modal/actions.js +0 -7
  193. package/src/Modal/getComponent.jsx +0 -32
  194. package/src/Modal/index.jsx +0 -12
  195. package/src/Modal/reducer.js +0 -40
  196. package/src/Modal/types.js +0 -6
  197. package/src/Modal/util.js +0 -15
  198. package/src/Payment/EstimatePrice/Description.jsx +0 -101
  199. package/src/Payment/EstimatePrice/PayBox.jsx +0 -173
  200. package/src/Payment/EstimatePrice/index.jsx +0 -63
  201. package/src/Payment/EstimatePrice/util.js +0 -15
  202. package/src/Payment/MobilpayForm.jsx +0 -77
  203. package/src/Payment/Modal/BankTransfer.jsx +0 -129
  204. package/src/Payment/Modal/CompanyValability.jsx +0 -14
  205. package/src/Payment/Modal/DoneForm.jsx +0 -209
  206. package/src/Payment/Modal/PaymentDone.jsx +0 -27
  207. package/src/Payment/Modal/index.js +0 -13
  208. package/src/Payment/actions.jsx +0 -22
  209. package/src/Payment/index.jsx +0 -124
  210. package/src/Payment/request.js +0 -50
  211. package/src/Payment/types.js +0 -14
  212. package/src/Payment/util.jsx +0 -52
  213. package/src/Payment/validate.js +0 -25
  214. package/src/Sidebar.jsx +0 -158
  215. package/src/Things.jsx +0 -35
  216. package/src/actions.js +0 -36
  217. package/src/config.js +0 -7
  218. package/src/dev/ErrorBoundary.jsx +0 -98
  219. package/src/dev/TheError.jsx +0 -87
  220. package/src/dev/index.js +0 -127
  221. package/src/dev/types.js +0 -10
  222. package/src/prod/SentryErrorBoundary.jsx +0 -98
  223. package/src/reducer/captchas.js +0 -44
  224. package/src/reducer/counties.js +0 -46
  225. package/src/reducer/index.js +0 -25
  226. package/src/reducer/module.jsx +0 -43
  227. package/src/style/.sass-lint.yml +0 -84
  228. package/src/style/.stylelintrc.json +0 -161
  229. package/src/style/_fancy-text.scss +0 -37
  230. package/src/style/_fix_bootstrap_placeholder_color.scss +0 -14
  231. package/src/style/_header-company.scss +0 -69
  232. package/src/style/_inputs.scss +0 -12
  233. package/src/style/_minimal.scss +0 -31
  234. package/src/style/_navigation.scss +0 -24
  235. package/src/style/_others.scss +0 -79
  236. package/src/style/index.scss +0 -7
  237. package/src/style/sidebar/_animations.scss +0 -21
  238. package/src/style/sidebar/_dark-theme.scss +0 -77
  239. package/src/style/sidebar/_scroll.scss +0 -37
  240. package/src/style/sidebar/_structure.scss +0 -299
  241. package/src/style/sidebar.scss +0 -4
  242. package/src/types.js +0 -31
  243. package/src/utility/calendar.js +0 -39
  244. package/src/utility/date.js +0 -100
  245. package/src/utility/index.js +0 -12
  246. package/src/utility/language.js +0 -17
  247. package/src/utility/mql.js +0 -3
  248. package/src/utility/normalize-test.js +0 -58
  249. package/src/utility/normalize.js +0 -119
  250. package/src/utility/numbers.js +0 -87
  251. package/src/utility/numeric.js +0 -114
  252. package/src/utility/others.jsx +0 -160
  253. package/src/utility/strings-test.js +0 -136
  254. package/src/utility/strings.js +0 -80
  255. package/src/utility/validation/common.js +0 -360
  256. package/src/utility/validation/index.js +0 -70
  257. package/src/utility/validation/specific.js +0 -9
  258. package/src/utility/validation/validate/bank-test.js +0 -129
  259. package/src/utility/validation/validate/bank.js +0 -176
  260. package/src/utility/validation/validate/cif-test.js +0 -105
  261. package/src/utility/validation/validate/cif.js +0 -44
  262. package/src/utility/validation/validate/cnp-test.js +0 -216
  263. package/src/utility/validation/validate/cnp.js +0 -261
  264. package/src/utility/validation/validate/email-test.js +0 -36
  265. package/src/utility/validation/validate/email.js +0 -6
  266. package/src/utility/validation/validate/index.js +0 -7
  267. package/webpack.config.js +0 -90
  268. package/x25.wiki/Account.md +0 -41
  269. package/x25.wiki/Company.md +0 -39
  270. package/x25.wiki/Header.md +0 -21
  271. package/x25.wiki/Home.md +0 -1
  272. package/x25.wiki/Inputs.md +0 -33
  273. package/x25.wiki/Messages.md +0 -27
  274. package/x25.wiki/Payment.md +0 -42
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ var _bank = require("./bank");
4
+
5
+ var valid = true,
6
+ notValid = false;
7
+
8
+ var wrong = ["", "1", "111", "RO", "RO14CECEGR", "RO14CECEGR0201RON0269170",
9
+ // "RO14CECEGR0201RON0269171", -- it is good
10
+ "RO14CECEGR0201RON0269172", "RO14CECEGR0201RON0269173", "RO14CECEGR0201RON0269174", "RO14CECEGR0201RON0269175", "RO14CECEGR0201RON0269176", "RO14CECEGR0201RON0269177", "RO14CECEGR0201RON0269178", "RO14CECEGR0201RON0269179"];
11
+
12
+ wrong.map(function (iban) {
13
+ return describe("given the wrong IBAN " + iban, function () {
14
+ it("should not be valid", function () {
15
+ expect((0, _bank.isValidBankAccount)(iban)).toBe(notValid);
16
+ });
17
+ });
18
+ });
19
+
20
+ var good = ["RO74RZBR0000060001635742", "RO20RNCB0146009062650001", "RO51BRDE190SV09770651900", "RO19RZBR0000060014507080", "RO14CECEGR0201RON0269171", "RO89RNCB0146009060300001", "RO69RNCB0146009053910001", "RO32RNCB0148009659280001", "RO32RZBR0000060008527863", "RO35BRDE190SV17599841900", "RO35BRDE190SV17599841900", "RO79RZBR0000060013901108", "RO61RZBR0000060005489107", "RO41CECEGR0230RON0350215", "RO25RZBR0000060008522848", "RO35RNCB0146127215140001", "RO50RZBR0000060006249397", "RO74rzbr0000060001635742",
21
+
22
+ // other countries
23
+ "AD12 0001 2030 2003 5910 0100", "AE07 0331 2345 6789 0123 456", "AL47 2121 1009 0000 0002 3569 8741", "AT61 1904 3002 3457 3201", "AZ21 NABZ 0000 0000 1370 1000 1944", "BA39 1290 0794 0102 8494", "BE62 5100 0754 7061", "BG80 BNBG 9661 1020 3456 78", "BH67 BMAG 0000 1299 1234 56", "CH93 0076 2011 6238 5295 7", "CY17 0020 0128 0000 0012 0052 7600", "CZ65 0800 0000 1920 0014 5399", "DE89 3704 0044 0532 0130 00", "DK50 0040 0440 1162 43", "EE38 2200 2210 2014 5685", "ES80 2310 0001 1800 0001 2345", "FI21 1234 5600 0007 85", "FO97 5432 0388 8999 44", "FR14 2004 1010 0505 0001 3M02 606",
24
+
25
+ /*
26
+ * "GB29 RBOS 6016 1331 9268 19",
27
+ * "GB99 RBOS 1234 5612 3456 78",
28
+ */
29
+ "GE29 NB00 0000 0101 9049 17", "GI75 NWBK 0000 0000 7099 453", "GL56 0444 9876 5432 10", "GR16 0110 1250 0000 0001 2300 695", "HR12 1001 0051 8630 0016 0", "HU42 1177 3016 1111 1018 0000 0000", "IE29 AIBK 9311 5212 3456 78", "IL62 0108 0000 0009 9999 999", "IS14 0159 2600 7654 5510 7303 39", "IT40 S054 2811 1010 0000 0123 456",
30
+ // "JO94 CBJO 0010 0000 0000 0131 0003 02",
31
+ "KW81 CBKU 0000 0000 0000 1234 5601 01", "LB62 0999 0000 0001 0019 0122 9114", "LI21 0881 0000 2324 013A A", "LT12 1000 0111 0100 1000", "LU28 0019 4006 4475 0000", "LV80 BANK 0000 4351 9500 1", "MC93 2005 2222 1001 1223 3M44 555", "MD24 AG00 0225 1000 1310 4168", "ME25 5050 0001 2345 6789 51", "MK072 5012 0000 0589 84", "MT84 MALT 0110 0001 2345 MTLC AST0 01S", "MU17 BOMM 0101 1010 3030 0200 000M UR", "NL39 RABO 0300 0652 64", "NO93 8601 1117 947", "PK36 SCBL 0000 0011 2345 6702", "PL60 1020 1026 0000 0422 7020 1111", "PT50 0002 0123 1234 5678 9015 4",
32
+ // "QA58 DOHB 0000 1234 5678 90AB CDEF G",
33
+ "RO49 AAAA 1B31 0075 9384 0000", "RS35 2600 0560 1001 6113 79", "SA03 8000 0000 6080 1016 7519", "SE35 5000 0000 0549 1000 0003", "SI56 1910 0000 0123 438", "SK31 1200 0000 1987 4263 7541", "SM86 U032 2509 8000 0000 0270 100", "TN59 1000 6035 1835 9847 8831", "TR33 0006 1005 1978 6457 8413 26"];
34
+
35
+ good.map(function (iban) {
36
+ return describe("given good IBAN " + iban, function () {
37
+ it("should be valid", function () {
38
+ expect((0, _bank.isValidBankAccount)(iban)).toBe(valid);
39
+ });
40
+ });
41
+ });
@@ -0,0 +1,176 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var isValidBankAccount = exports.isValidBankAccount = function isValidBankAccount(rawValue) {
7
+
8
+ // Remove spaces and to upper case
9
+ var checkPosition = 4,
10
+ iban = rawValue.replace(/ /g, "").toUpperCase(),
11
+ hasGoodCountryCode = function hasGoodCountryCode() {
12
+
13
+ if (iban.length <= 2) {
14
+ return false;
15
+ }
16
+
17
+ var countrycode = iban.substring(0, 2),
18
+ bbancountrypatterns = {
19
+ "AD": "\\d{8}[\\dA-Z]{12}",
20
+ "AE": "\\d{3}\\d{16}",
21
+ "AL": "\\d{8}[\\dA-Z]{16}",
22
+ "AT": "\\d{16}",
23
+ "AZ": "[\\dA-Z]{4}\\d{20}",
24
+ "BA": "\\d{16}",
25
+ "BE": "\\d{12}",
26
+ "BG": "[A-Z]{4}\\d{6}[\\dA-Z]{8}",
27
+ "BH": "[A-Z]{4}[\\dA-Z]{14}",
28
+ "BR": "\\d{23}[A-Z][\\dA-Z]",
29
+ "CH": "\\d{5}[\\dA-Z]{12}",
30
+ "CR": "\\d{17}",
31
+ "CY": "\\d{8}[\\dA-Z]{16}",
32
+ "CZ": "\\d{20}",
33
+ "DE": "\\d{18}",
34
+ "DK": "\\d{14}",
35
+ "DO": "[A-Z]{4}\\d{20}",
36
+ "EE": "\\d{16}",
37
+ "ES": "\\d{20}",
38
+ "FI": "\\d{14}",
39
+ "FO": "\\d{14}",
40
+ "FR": "\\d{10}[\\dA-Z]{11}\\d{2}",
41
+ "GB": "[A-Z]{4}\\d{14}",
42
+ "GE": "[\\dA-Z]{2}\\d{16}",
43
+ "GI": "[A-Z]{4}[\\dA-Z]{15}",
44
+ "GL": "\\d{14}",
45
+ "GR": "\\d{7}[\\dA-Z]{16}",
46
+ "GT": "[\\dA-Z]{4}[\\dA-Z]{20}",
47
+ "HR": "\\d{17}",
48
+ "HU": "\\d{24}",
49
+ "IE": "[\\dA-Z]{4}\\d{14}",
50
+ "IL": "\\d{19}",
51
+ "IS": "\\d{22}",
52
+ "IT": "[A-Z]\\d{10}[\\dA-Z]{12}",
53
+ "KW": "[A-Z]{4}[\\dA-Z]{22}",
54
+ "KZ": "\\d{3}[\\dA-Z]{13}",
55
+ "LB": "\\d{4}[\\dA-Z]{20}",
56
+ "LI": "\\d{5}[\\dA-Z]{12}",
57
+ "LT": "\\d{16}",
58
+ "LU": "\\d{3}[\\dA-Z]{13}",
59
+ "LV": "[A-Z]{4}[\\dA-Z]{13}",
60
+ "MC": "\\d{10}[\\dA-Z]{11}\\d{2}",
61
+ "MD": "[\\dA-Z]{2}\\d{18}",
62
+ "ME": "\\d{18}",
63
+ "MK": "\\d{3}[\\dA-Z]{10}\\d{2}",
64
+ "MR": "\\d{23}",
65
+ "MT": "[A-Z]{4}\\d{5}[\\dA-Z]{18}",
66
+ "MU": "[A-Z]{4}\\d{19}[A-Z]{3}",
67
+ "NL": "[A-Z]{4}\\d{10}",
68
+ "NO": "\\d{11}",
69
+ "PK": "[\\dA-Z]{4}\\d{16}",
70
+ "PL": "\\d{24}",
71
+ "PS": "[\\dA-Z]{4}\\d{21}",
72
+ "PT": "\\d{21}",
73
+ "RO": "[A-Z]{4}[\\dA-Z]{16}",
74
+ "RS": "\\d{18}",
75
+ "SA": "\\d{2}[\\dA-Z]{18}",
76
+ "SE": "\\d{20}",
77
+ "SI": "\\d{15}",
78
+ "SK": "\\d{20}",
79
+ "SM": "[A-Z]\\d{10}[\\dA-Z]{12}",
80
+ "TN": "\\d{20}",
81
+ "TR": "\\d{5}[\\dA-Z]{17}",
82
+ "VG": "[\\dA-Z]{4}\\d{16}"
83
+ },
84
+ bbanpattern = bbancountrypatterns[countrycode];
85
+
86
+ /*
87
+ * As new countries will start using IBAN in the
88
+ * future, we only check if the countrycode is known.
89
+ * This prevents false negatives, while almost all
90
+ * false positives introduced by this, will be caught
91
+ * by the checksum validation below anyway.
92
+ * Strict checking should return FALSE for unknown
93
+ * countries.
94
+ */
95
+ if (typeof bbanpattern === "undefined") {
96
+ return false;
97
+ }
98
+
99
+ var ibanregexp = new RegExp("^[A-Z]{2}\\d{2}" + bbanpattern + "$", "u");
100
+
101
+ // Invalid country specific format
102
+ return ibanregexp.test(iban);
103
+ },
104
+ hasGoodRest = function hasGoodRest() {
105
+ var getCheckDigits = function getCheckDigits() {
106
+
107
+ var getCheck = function getCheck() {
108
+ var first = String(iban.substring(checkPosition, iban.length)),
109
+ second = String(iban.substring(0, checkPosition));
110
+
111
+ return first + second;
112
+ },
113
+ ibancheck = getCheck();
114
+
115
+ var leadingZeroes = true,
116
+ value = "";
117
+
118
+ for (var index = 0; index < ibancheck.length; index += 1) {
119
+ var character = ibancheck.charAt(index);
120
+
121
+ if (character !== "0") {
122
+ leadingZeroes = false;
123
+ }
124
+
125
+ if (!leadingZeroes) {
126
+ value += "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".indexOf(character);
127
+ }
128
+ }
129
+
130
+ return value;
131
+ },
132
+ ibancheckdigits = getCheckDigits(),
133
+ nrToDevide = 97,
134
+ getOperator = function getOperator(_ref) {
135
+ var cRest = _ref.cRest,
136
+ cChar = _ref.cChar;
137
+
138
+ var rest = cRest === 0 ? "" : String(cRest);
139
+
140
+ return Number("" + rest + cChar);
141
+ };
142
+
143
+ var currentRest = 0;
144
+
145
+ for (var index = 0; index < ibancheckdigits.length; index += 1) {
146
+ var cChar = ibancheckdigits.charAt(index),
147
+ cOperator = getOperator({
148
+ cRest: currentRest,
149
+ cChar: 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
+ };
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ var _cif = require("./cif");
4
+
5
+ var valid = true,
6
+ notValid = false;
7
+
8
+ var wrong = ["adsasd",
9
+
10
+ // too short < 6
11
+ "00",
12
+
13
+ // too long > 10
14
+ "00000000001",
15
+
16
+ // contains other things
17
+ "aaaaaaaaaa", "1450123", "13880060", "13880061", "13880062",
18
+ // "51584214", // <-- this is good
19
+ "13880064", "13880065", "13880066", "13880067", "13880068", "13880069"];
20
+
21
+ wrong.map(function (cif) {
22
+ return describe("given the wrong CIF " + cif, function () {
23
+ it("should not be valid", function () {
24
+ expect((0, _cif.isValidCIF)(cif)).toBe(notValid);
25
+ });
26
+ });
27
+ });
28
+
29
+ var good = ["4446651", "3678190", "4352719", "3627676", "7525881", "4347666", "3372840", "5217524", "4317819", "4192600", "4266928", "4233815", "4288004", "4300787", "4300574", "4332134", "3519380", "4375178", "4297924", "3127336", "11078781", "3897033", "4541874", "4605609", "4245518", "4358002", "4230436", "4266898", "2613486", "4318113", "2844154", "4222310", "2540830", "4287378", "3897343", "4540062", "5397247", "4556140", "4231881", "4244393", "4280213", "4323179", "4567890", "6412248", "4269304", "4321658", "4494721", "4404613", "51584214"];
30
+
31
+ good.map(function (cif) {
32
+ return describe("given the good CIF " + cif, function () {
33
+ it("should be valid", function () {
34
+ expect((0, _cif.isValidCIF)(cif)).toBe(valid);
35
+ });
36
+ });
37
+ });
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var isValidCIF = exports.isValidCIF = function isValidCIF(rawValue) {
7
+ var len = rawValue.length,
8
+ value = Number(rawValue),
9
+ ten = 10,
10
+ eleven = 11,
11
+ controlDigit1 = value % ten,
12
+ upperLimit = 10,
13
+ lowerLimit = 4,
14
+ getControlDigit2 = function getControlDigit2() {
15
+ var controlNumber = 753217532,
16
+ controlDigit2 = 0,
17
+ current = parseInt(value / ten, ten),
18
+ accumulator = 0;
19
+
20
+ while (current > 0) {
21
+ var controlDigit = controlNumber % ten;
22
+
23
+ accumulator += current % ten * controlDigit;
24
+
25
+ current = parseInt(current / ten, ten);
26
+ controlNumber = parseInt(controlNumber / ten, 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
+ };
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+
3
+ var _cnp = require("./cnp");
4
+
5
+ var valid = true,
6
+ notValid = false;
7
+
8
+ var wrongCNPs = [
9
+
10
+ // less than 13 characters
11
+ "000",
12
+
13
+ // more than 13 characters
14
+ "00000000000000",
15
+
16
+ // not all digits
17
+ " ", "a234567890123", "1x34567890123", "12y4567890123", "123(567890123", "1234*67890123", "12345-7890123", "123456+890123", "1234567`90123", "12345678!0123", "123456789@123", "12345678901&3", "123456789012=",
18
+
19
+ // Digit 1 not 0
20
+ "0000000000000",
21
+
22
+ /*
23
+ * Wrong month
24
+ * Too small
25
+ */
26
+ "1230000000000",
27
+ // Too big
28
+ "1231300000000", "1234500000000", "1239900000000",
29
+
30
+ // Wrong date
31
+ "1000100000000", "1000100000000", "1231200000000", "3431250000000", "8430100000000", "6431132000000", "5160230000000",
32
+
33
+ /*
34
+ * Wrong County
35
+ * 0
36
+ */
37
+ "1930426000000",
38
+
39
+ // Too big
40
+ "1930426530000", "1930426990000",
41
+
42
+ // Number - allowed only 001 --> 999
43
+ "1930426010000",
44
+
45
+ // Check controll all posible conbinations
46
+ "1930426450030", "1930426450031", "1930426450032", "1930426450033", "1930426450034",
47
+ // "1930426450035", // --> this is good
48
+ "1930426450036", "1930426450037", "1930426450038", "1930426450039", "1730513635451"];
49
+
50
+ wrongCNPs.map(function (cnp) {
51
+ return describe("given the wrong CNP " + cnp, function () {
52
+ it("should not be valid", function () {
53
+ expect((0, _cnp.isValidCNP)(cnp)).toBe(notValid);
54
+ });
55
+ });
56
+ });
57
+
58
+ var goodCNPs = ["1601224522490",
59
+ // list from http://cnp-orange-young.blogspot.ro/
60
+ "1851021345131", "1920617149053", "1870505168646", "1870619152998", "1921204325416", "1931011351347", "1860601214764", "1930114152084", "1930729213031", "1931110257176", "1900806182888", "1920201181713", "1911202393786", "1860114313017", "1900129321797", "1910319357474", "1881110136241", "1910313389932", "1930324128027", "1860713267955", "1920110059921", "1920323137670", "1910524257786", "1910219353588", "1921113049026", "1910510171180", "1921219189118", "1930614296921", "1930408137659", "1860525171600", "1871008113318", "1900809164551", "1870418305339", "1920622093590", "1860228422041", "1881024199710", "1901119289825", "1870623151354", "1880717053385", "1860331281263", "1921127239892", "1860726084246", "1891209392109", "1870610429939", "1891101155151", "1900515188610", "1900817347850", "1850603113108", "1920219031621", "1880716319353", "1851123072213", "1890503074079", "1920929194685", "1930604396824", "1920721211943", "1911125017410", "1920328331453", "1891012055602", "1850412422567", "1900830012030", "1901109372453", "1901119063169", "1910801238953", "1850126336642", "1870619334654", "1880930146221", "1861019351849", "1930502103999", "1930425361934", "1871108269030", "1860622273209", "1920723362204", "1880919016077", "1860627124609", "1930210191367", "1920306379899", "1860621221169", "1890514289320", "1920421395061", "1930426272907", "1861224076805", "1850204207530", "1930726241832", "1920229184105", "1910318245177", "1871225154992", "1890425099446", "1920918187490", "1911017023863", "1900514401426", "1860117328230", "1861019339785", "1870119334824", "1880316079025", "1910216018631", "1920425405811", "1920904145205", "1881201016278", "1920731125084", "1901003395568", "1590512521591", "1660418230010", "1891119450065", "1920310430037", "1920504521696", "1930426450035", "2770926521590", "2830111410090", "2880330521699", "2900117521690", "2910825522143"];
61
+
62
+ goodCNPs.map(function (cnp) {
63
+ return describe("given the good CNP " + cnp, function () {
64
+ it("should be valid", function () {
65
+ expect((0, _cnp.isValidCNP)(cnp)).toBe(valid);
66
+ });
67
+ });
68
+ });
@@ -0,0 +1,193 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ /* eslint-disable no-magic-numbers, max-statements */
8
+
9
+ var isValidCNP = exports.isValidCNP = function isValidCNP(rawValue) {
10
+
11
+ var decimalSystem = 10,
12
+ position = {
13
+ yearMillenium: 0,
14
+ sex: 0,
15
+
16
+ yearDecades: 1,
17
+ yearUnits: 2,
18
+
19
+ monthDecimals: 3,
20
+ monthUnits: 4,
21
+
22
+ dayDecimals: 5,
23
+ dayUnits: 6,
24
+
25
+ countyDecimals: 7,
26
+ countyUnits: 8,
27
+
28
+ numberHundreds: 9,
29
+ numberDecimals: 10,
30
+ numberUnits: 11,
31
+
32
+ controlDigit: 12
33
+ },
34
+ getCNP = function getCNP(raw) {
35
+
36
+ var hashResult = 0;
37
+
38
+ var hashTable = [2, 7, 9, 1, 4, 6, 3, 5, 8, 2, 7, 9],
39
+ normalLength = 13,
40
+ cnp = [];
41
+
42
+ var reduceHash = function reduceHash(rawHash) {
43
+ var nrOfDigits = 11,
44
+ reduced = parseInt(rawHash % nrOfDigits, decimalSystem);
45
+
46
+ if (reduced === 10) {
47
+ return 1;
48
+ }
49
+
50
+ return reduced;
51
+ };
52
+
53
+ if (raw.length !== normalLength) {
54
+ throw new Error("The length [actual:" + raw.length + "]\n should be " + normalLength + " characters");
55
+ }
56
+
57
+ if (raw[0] === "0") {
58
+ throw new Error("The sex can not be 0");
59
+ }
60
+
61
+ var controlDigit = parseInt(raw.charAt(position.controlDigit), decimalSystem);
62
+
63
+ if (isNaN(controlDigit)) {
64
+ throw new Error("The control digit should be number");
65
+ }
66
+
67
+ for (var index = 0; index < 12; index += 1) {
68
+
69
+ var rawChar = raw.charAt(index),
70
+ parsedValue = parseInt(rawChar, decimalSystem),
71
+ correspondingHashNumber = hashTable[index];
72
+
73
+ if (isNaN(parsedValue)) {
74
+ throw new Error("The char at position " + index + " should be numeric");
75
+ }
76
+
77
+ cnp[index] = parsedValue;
78
+ hashResult += parsedValue * correspondingHashNumber;
79
+ }
80
+
81
+ if (controlDigit !== reduceHash(hashResult)) {
82
+ throw new Error("\n The control digit is not good\n [" + controlDigit + " === " + reduceHash(hashResult) + "]\n ");
83
+ }
84
+
85
+ return cnp;
86
+ },
87
+ validate = function validate(cnp) {
88
+ var getCNPDigit = function getCNPDigit(currentPosition) {
89
+ return cnp[currentPosition];
90
+ },
91
+ isValidDate = function isValidDate() {
92
+ var getYear = function getYear() {
93
+ var computeYear = function computeYear() {
94
+ var yearMillenium = position.yearMillenium,
95
+ yearDecades = position.yearDecades,
96
+ yearUnits = position.yearUnits;
97
+
98
+
99
+ var year = getCNPDigit(yearDecades) * 10 + getCNPDigit(yearUnits);
100
+
101
+ switch (getCNPDigit(yearMillenium)) {
102
+ case 1:
103
+ case 2:
104
+ year += 1900;
105
+ break;
106
+ case 3:
107
+ case 4:
108
+ year += 1800;
109
+ break;
110
+ case 5:
111
+ case 6:
112
+ year += 2000;
113
+ break;
114
+
115
+ // 7,8,9
116
+ default:
117
+ {
118
+ year += 2000;
119
+
120
+ var today = new Date(),
121
+ tempYear = parseInt(today.getYear(), 10) - 14;
122
+
123
+ if (year > tempYear) {
124
+ year -= 100;
125
+ }
126
+ }
127
+ break;
128
+ }
129
+
130
+ return year;
131
+ },
132
+ year = computeYear();
133
+
134
+ if (year < 1800 || year > 2099) {
135
+ throw new Error("\n Year [actual: " + String(year) + "] is not valid.\n It should be between 1800 and 2099\n ");
136
+ }
137
+
138
+ return year;
139
+ };
140
+
141
+ var year = getYear();
142
+
143
+ var monthDecimals = position.monthDecimals,
144
+ monthUnits = position.monthUnits,
145
+ dayDecimals = position.dayDecimals,
146
+ dayUnits = position.dayUnits,
147
+ month = getCNPDigit(monthDecimals) * 10 + getCNPDigit(monthUnits),
148
+ day = getCNPDigit(dayDecimals) * 10 + getCNPDigit(dayUnits),
149
+ jsMonth = month - 1,
150
+ date = new Date(year, jsMonth, day, 0, 0, 0, 0);
151
+
152
+
153
+ if (date.getFullYear() !== year || date.getMonth() !== jsMonth || date.getDate() !== day) {
154
+ throw new Error("\n The given date\n [\n year -> " + String(year) + "\n month -> " + String(month) + "\n day -> " + String(day) + "\n ]");
155
+ }
156
+ },
157
+ isValidCounty = function isValidCounty() {
158
+ var countyDecimals = position.countyDecimals,
159
+ countyUnits = position.countyUnits,
160
+ lowerLimit = 1,
161
+ upperLimit = 52,
162
+ code = getCNPDigit(countyDecimals) * 10 + getCNPDigit(countyUnits);
163
+
164
+
165
+ if (code < lowerLimit || code > upperLimit) {
166
+ throw new Error("\n The country code is invalid [actual: " + code + "],\n should be between: " + lowerLimit + " <= " + code + " >= " + upperLimit + "\n ");
167
+ }
168
+ },
169
+ isValidNumber = function isValidNumber() {
170
+ var numberHundreds = position.numberHundreds,
171
+ numberDecimals = position.numberDecimals,
172
+ numberUnits = position.numberUnits,
173
+ number = getCNPDigit(numberHundreds) * 100 + getCNPDigit(numberDecimals) * 10 + getCNPDigit(numberUnits);
174
+
175
+
176
+ if (number === 0) {
177
+ throw new Error("The number should not be 0");
178
+ }
179
+ };
180
+
181
+ isValidDate();
182
+ isValidCounty();
183
+ isValidNumber();
184
+ };
185
+
186
+ try {
187
+ validate(getCNP(rawValue));
188
+
189
+ return true;
190
+ } catch (error) {
191
+ return false;
192
+ }
193
+ };