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
@@ -1,360 +0,0 @@
1
- // @flow
2
-
3
- type ValidatorResult = {
4
- notValid: bool;
5
- error: null | string;
6
- }
7
-
8
- type ValidateStringOptions = {
9
- what?:string;
10
- min?: number;
11
- max?: number;
12
- optional?: bool;
13
- };
14
-
15
- type ValidateFloatOptions = {
16
- min?: number;
17
- max?: number;
18
- optional?: bool;
19
- integer?: bool;
20
- };
21
-
22
- type AllOptions = ValidateFloatOptions | ValidateStringOptions;
23
-
24
- type Field = {
25
- field: string;
26
- options: AllOptions;
27
- }
28
-
29
- type Fields = Array<Field>;
30
- type Validator = (value? : string) => ValidatorResult;
31
- type Checker = (options : any) => Validator;
32
- type ValidateFields = (fields : Fields, checker : Checker) => any;
33
-
34
- import {
35
- isValidBankAccount,
36
- isValidCIF,
37
- isValidCNP,
38
- isValidDateStamp,
39
- isValidEmail,
40
- } from "./validate";
41
-
42
- const errMessageSelectField = "Selectează câmpul";
43
-
44
- const
45
- limitTense = 19,
46
- getNumberTense = (value : number) => value > limitTense ? `${value} de` : String(value);
47
-
48
- export const validateHumanNid = (optional : ?bool = false) => (value : string) => {
49
- const
50
- notValid = (
51
- optional && (
52
- typeof value !== "undefined" &&
53
- value !== "" &&
54
- !isValidCNP(value)
55
- )
56
- ) || (
57
- !optional && (
58
- typeof value === "undefined" ||
59
- !isValidCNP(value)
60
- )
61
- ),
62
- error = notValid ? "Trebuie un CNP valid" : null;
63
-
64
- return {
65
- notValid,
66
- error,
67
- };
68
- };
69
-
70
- export const validateCif = (value : string) => {
71
- const
72
- notValid = typeof value === "undefined" || !isValidCIF(value),
73
- error = notValid ? "Trebuie un cod valid de identificare fiscală" : null;
74
-
75
- return {
76
- notValid,
77
- error,
78
- };
79
- };
80
-
81
- export const validateBankAccount = (value : string) => {
82
- const
83
- notValid = (
84
- typeof value !== "undefined" &&
85
- value !== "" &&
86
- !isValidBankAccount(value)
87
- ),
88
- error = notValid ? "Trebuie furnizat un IBAN valid" : null;
89
-
90
- return {
91
- notValid,
92
- error,
93
- };
94
- };
95
-
96
- export const validateEmail = ({ optional } : { optional : boolean }) => (value : string) => {
97
- const
98
- notValid = (
99
- optional && (
100
- typeof value !== "undefined" &&
101
- value !== "" &&
102
- !isValidEmail(value)
103
- )
104
- ) || (
105
- !optional && (
106
- typeof value === "undefined" ||
107
- !isValidEmail(value)
108
- )
109
- ),
110
- error = notValid ? "Trebuie o adresă validă de e-mail" : null;
111
-
112
- return {
113
- notValid,
114
- error,
115
- };
116
- };
117
-
118
-
119
- export const validateOptionalDate = (value : string) => {
120
- const
121
- notValid = !(
122
- typeof value === "undefined" || value === "" || value === null || (
123
- isValidDateStamp(value)
124
- )
125
- ),
126
- error = notValid ? "Trebuie o dată validă (ZZ.LL.ANUL)" : null;
127
-
128
- return {
129
- notValid,
130
- error,
131
- };
132
- };
133
-
134
- export const validateDate = (value : string) => {
135
- const
136
- notValid = !(
137
- (typeof value !== "undefined") && isValidDateStamp(value)
138
- ),
139
- error = notValid ? "Trebuie o dată validă (ZZ.LL.ANUL)" : null;
140
-
141
- return {
142
- notValid,
143
- error,
144
- };
145
- };
146
-
147
- const isInt = (value) => (
148
- !isNaN(value) &&
149
- parseInt(Number(value),
150
- 10) === value && !isNaN(parseInt(value,
151
- 10))
152
- );
153
-
154
- const validateNumberRange = ({ min, max, value, integer }) => {
155
- if (typeof value !== "number") {
156
- return false;
157
- }
158
-
159
- const
160
- numeric = Number(value),
161
- hasMin = typeof min === "number",
162
- hasMax = typeof max === "number";
163
-
164
- return (
165
- (typeof value !== "undefined") &&
166
- (value !== "") &&
167
- !isNaN(value) &&
168
- (!integer || (integer && isInt(value))) &&
169
- (!hasMin || (typeof min === "number" && numeric >= min)) &&
170
- (!hasMax || (typeof max === "number" && numeric <= max))
171
- );
172
- };
173
-
174
- const getNumberRangeError = ({ min, max, integer }) => {
175
-
176
- const
177
- minTense = typeof min === "number" ? getNumberTense(min) : "",
178
- maxTense = typeof max === "number" ? getNumberTense(max) : "",
179
- range = (
180
- (typeof min === "number" && typeof max === "number") ? ` între ${minTense} și ${maxTense}` : (
181
- typeof max === "number" ? ` până în ${maxTense}` : (
182
- typeof min === "number" ? ` mai mare ca ${minTense}` : ""
183
- )
184
- )
185
- );
186
-
187
- return `Trebuie un număr ${integer ? "întreg" : "cu virgulă"} ${range}`;
188
- };
189
-
190
- export const validateFloat : Checker = (props) => (value) => {
191
- const { min, max, optional, integer } = props;
192
-
193
- const
194
- whenOptional = optional && !(
195
- typeof value === "undefined" || value === null || (
196
- validateNumberRange({
197
- min,
198
- max,
199
- value,
200
- integer,
201
- })
202
- )
203
- ),
204
- whenRequired = !optional && !(
205
- (typeof value !== "undefined" && value !== null) && validateNumberRange({
206
- min,
207
- max,
208
- value,
209
- integer,
210
- })
211
- ),
212
- notValid = whenOptional || whenRequired,
213
- error = notValid ? getNumberRangeError({
214
- min,
215
- max,
216
- integer,
217
- }) : "";
218
-
219
- return {
220
- notValid,
221
- error,
222
- };
223
- };
224
-
225
- const getStringTense = ({ min, max, what }) => {
226
- const
227
- maxTense = max ? getNumberTense(max) : "",
228
- minTense = min ? getNumberTense(min) : "",
229
- isBetween = (typeof max === "number" && typeof min === "number"),
230
- rangeError = isBetween ? `între ${minTense} și ${maxTense}` : (
231
- typeof max === "number" ? `până în ${maxTense}` : (
232
- typeof min === "number" ? `cel puțin ${minTense}` : ""
233
- )
234
- );
235
-
236
- return `${what} are ${rangeError} caractere`;
237
- };
238
-
239
- const validateStringRange = ({ min, max, value }) => {
240
- if (typeof value !== "string") {
241
- return false;
242
- }
243
-
244
- const
245
- length = typeof value === "undefined" ? 0 : value.length,
246
- hasMin = typeof min === "number",
247
- hasMax = typeof max === "number";
248
-
249
- return (
250
- (!hasMin || (typeof min === "number" && length >= min)) &&
251
- (!hasMax || (typeof max === "number" && length <= max))
252
- );
253
- };
254
-
255
-
256
- export const validateString : Checker = (props) => (value) => {
257
- const { what = "Câmpul", min, max, optional } = props;
258
- const
259
- whenOptional = optional && !(
260
- typeof value === "undefined" || value === null || (
261
- validateStringRange({
262
- min,
263
- max,
264
- value,
265
- })
266
- )
267
- ),
268
- whenRequired = !optional && !(
269
- (typeof value !== "undefined" && value !== null) && validateStringRange({
270
- min,
271
- max,
272
- value,
273
- })
274
- ),
275
- notValid = whenOptional || whenRequired,
276
- error = notValid ? getStringTense({
277
- min,
278
- max,
279
- what,
280
- }) : "";
281
-
282
- return {
283
- notValid,
284
- error,
285
- };
286
- };
287
-
288
- export const validateSelect = (message? : string) => (value : string) => {
289
- const
290
- notValid = (
291
- (typeof value === "undefined") || value === null || value === ""
292
- ),
293
- error = notValid ? (typeof message === "undefined" ? errMessageSelectField : message) : null;
294
-
295
- return {
296
- notValid,
297
- error,
298
- };
299
- };
300
-
301
- export const validateID = (message? : string) => (value : string) => {
302
- const
303
- notValid = !(
304
- typeof value === "number" && !isNaN(value)
305
- ),
306
- error = notValid ? (typeof message === "undefined" ? errMessageSelectField : message) : null;
307
-
308
- return {
309
- notValid,
310
- error,
311
- };
312
- };
313
-
314
- export const validateCaptchaSolution = (value : string) => {
315
- const
316
- pattern = /^\d{6}$/u,
317
- notValid = (
318
- typeof value !== "undefined" &&
319
- !pattern.test(value)
320
- ),
321
- error = notValid ? "Codul are exact șase cifre" : null;
322
-
323
- return {
324
- notValid,
325
- error,
326
- };
327
- };
328
-
329
- export const validateResetToken = (value : string) => {
330
- const
331
- tokenSize = 64,
332
- notValid = (
333
- typeof value === "undefined" ||
334
- String(value).length !== tokenSize
335
- ),
336
- error = notValid ? "Codul nu este valid" : null;
337
-
338
- return {
339
- notValid,
340
- error,
341
- };
342
- };
343
-
344
- export const validateHumanName = validateString({
345
- min : 3,
346
- max : 40,
347
- });
348
-
349
- export const validatePassword = validateString({
350
- min : 6,
351
- max : 25,
352
- });
353
-
354
- export const validateFields : ValidateFields = (fields, checker) => (
355
- fields.reduce((accumulator, { field, options }) => ({
356
- ...accumulator,
357
-
358
- [field]: checker(options),
359
- }), {})
360
- );
@@ -1,70 +0,0 @@
1
- // @flow
2
-
3
- export * from "./common";
4
- export * from "./specific";
5
- export * from "./validate";
6
-
7
- const processErrors = ({ error, isArray, _error, arrayErrors }, { field, errors }) => {
8
- if (isArray) {
9
- if (arrayErrors) {
10
- errors[field] = arrayErrors;
11
- } else {
12
- errors[field] = { _error };
13
- }
14
- } else {
15
- errors[field] = error;
16
- }
17
- };
18
-
19
- export const extractErrorsFromCheckers = (checkers : any) => (values : any) => {
20
- const errors = {};
21
-
22
- for (const field in checkers) {
23
- if (Object.prototype.hasOwnProperty.call(checkers,
24
- field)) {
25
- const
26
- checker = checkers[field],
27
- result = checker(values.get(field)),
28
- { notValid } = result;
29
-
30
- if (notValid) {
31
- processErrors(result,
32
- {
33
- field,
34
- errors,
35
- });
36
- }
37
- }
38
- }
39
-
40
- return errors;
41
- };
42
-
43
- export const performValidateRows = (items : any, checkers : any) => {
44
- const
45
- notValid = (
46
- (typeof items === "undefined") ||
47
- items.size === 0
48
- );
49
-
50
- if (notValid) {
51
- return {
52
- notValid,
53
- _error : "Adaugă cel puțin un rând",
54
- isArray : true,
55
- };
56
- }
57
-
58
- const arrayErrors = items.reduce((previous, item, key) => {
59
- previous[key] = extractErrorsFromCheckers(checkers)(item);
60
-
61
- return previous;
62
- }, []);
63
-
64
- return {
65
- notValid: true,
66
- arrayErrors,
67
-
68
- isArray: true,
69
- };
70
- };
@@ -1,9 +0,0 @@
1
- // @flow
2
-
3
- import { validateFloat } from "./common";
4
-
5
- export const validateDay = validateFloat({
6
- min : 1,
7
- max : 31,
8
- integer : true,
9
- });
@@ -1,129 +0,0 @@
1
- import { isValidBankAccount } from "./bank";
2
-
3
- const valid = true,
4
- notValid = false;
5
-
6
-
7
- const wrong = [
8
- "",
9
- "1",
10
- "111",
11
- "RO",
12
- "RO14CECEGR",
13
- "RO14CECEGR0201RON0269170",
14
- // "RO14CECEGR0201RON0269171", -- it is good
15
- "RO14CECEGR0201RON0269172",
16
- "RO14CECEGR0201RON0269173",
17
- "RO14CECEGR0201RON0269174",
18
- "RO14CECEGR0201RON0269175",
19
- "RO14CECEGR0201RON0269176",
20
- "RO14CECEGR0201RON0269177",
21
- "RO14CECEGR0201RON0269178",
22
- "RO14CECEGR0201RON0269179",
23
- ];
24
-
25
- wrong.map((iban) => (
26
- describe(`given the wrong IBAN ${iban}`,
27
- () => {
28
- it("should not be valid",
29
- () => {
30
- expect(isValidBankAccount(iban)).toBe(notValid);
31
- });
32
- })
33
- ));
34
-
35
- const good = [
36
- "RO74RZBR0000060001635742",
37
- "RO20RNCB0146009062650001",
38
- "RO51BRDE190SV09770651900",
39
- "RO19RZBR0000060014507080",
40
- "RO14CECEGR0201RON0269171",
41
- "RO89RNCB0146009060300001",
42
- "RO69RNCB0146009053910001",
43
- "RO32RNCB0148009659280001",
44
- "RO32RZBR0000060008527863",
45
- "RO35BRDE190SV17599841900",
46
- "RO35BRDE190SV17599841900",
47
- "RO79RZBR0000060013901108",
48
- "RO61RZBR0000060005489107",
49
- "RO41CECEGR0230RON0350215",
50
- "RO25RZBR0000060008522848",
51
- "RO35RNCB0146127215140001",
52
- "RO50RZBR0000060006249397",
53
-
54
- "RO74rzbr0000060001635742",
55
-
56
- // other countries
57
- "AD12 0001 2030 2003 5910 0100",
58
- "AE07 0331 2345 6789 0123 456",
59
- "AL47 2121 1009 0000 0002 3569 8741",
60
- "AT61 1904 3002 3457 3201",
61
- "AZ21 NABZ 0000 0000 1370 1000 1944",
62
- "BA39 1290 0794 0102 8494",
63
- "BE62 5100 0754 7061",
64
- "BG80 BNBG 9661 1020 3456 78",
65
- "BH67 BMAG 0000 1299 1234 56",
66
- "CH93 0076 2011 6238 5295 7",
67
- "CY17 0020 0128 0000 0012 0052 7600",
68
- "CZ65 0800 0000 1920 0014 5399",
69
- "DE89 3704 0044 0532 0130 00",
70
- "DK50 0040 0440 1162 43",
71
- "EE38 2200 2210 2014 5685",
72
- "ES80 2310 0001 1800 0001 2345",
73
- "FI21 1234 5600 0007 85",
74
- "FO97 5432 0388 8999 44",
75
- "FR14 2004 1010 0505 0001 3M02 606",
76
-
77
- /*
78
- * "GB29 RBOS 6016 1331 9268 19",
79
- * "GB99 RBOS 1234 5612 3456 78",
80
- */
81
- "GE29 NB00 0000 0101 9049 17",
82
- "GI75 NWBK 0000 0000 7099 453",
83
- "GL56 0444 9876 5432 10",
84
- "GR16 0110 1250 0000 0001 2300 695",
85
- "HR12 1001 0051 8630 0016 0",
86
- "HU42 1177 3016 1111 1018 0000 0000",
87
- "IE29 AIBK 9311 5212 3456 78",
88
- "IL62 0108 0000 0009 9999 999",
89
- "IS14 0159 2600 7654 5510 7303 39",
90
- "IT40 S054 2811 1010 0000 0123 456",
91
- // "JO94 CBJO 0010 0000 0000 0131 0003 02",
92
- "KW81 CBKU 0000 0000 0000 1234 5601 01",
93
- "LB62 0999 0000 0001 0019 0122 9114",
94
- "LI21 0881 0000 2324 013A A",
95
- "LT12 1000 0111 0100 1000",
96
- "LU28 0019 4006 4475 0000",
97
- "LV80 BANK 0000 4351 9500 1",
98
- "MC93 2005 2222 1001 1223 3M44 555",
99
- "MD24 AG00 0225 1000 1310 4168",
100
- "ME25 5050 0001 2345 6789 51",
101
- "MK072 5012 0000 0589 84",
102
- "MT84 MALT 0110 0001 2345 MTLC AST0 01S",
103
- "MU17 BOMM 0101 1010 3030 0200 000M UR",
104
- "NL39 RABO 0300 0652 64",
105
- "NO93 8601 1117 947",
106
- "PK36 SCBL 0000 0011 2345 6702",
107
- "PL60 1020 1026 0000 0422 7020 1111",
108
- "PT50 0002 0123 1234 5678 9015 4",
109
- // "QA58 DOHB 0000 1234 5678 90AB CDEF G",
110
- "RO49 AAAA 1B31 0075 9384 0000",
111
- "RS35 2600 0560 1001 6113 79",
112
- "SA03 8000 0000 6080 1016 7519",
113
- "SE35 5000 0000 0549 1000 0003",
114
- "SI56 1910 0000 0123 438",
115
- "SK31 1200 0000 1987 4263 7541",
116
- "SM86 U032 2509 8000 0000 0270 100",
117
- "TN59 1000 6035 1835 9847 8831",
118
- "TR33 0006 1005 1978 6457 8413 26",
119
- ];
120
-
121
- good.map((iban) => (
122
- describe(`given good IBAN ${iban}`,
123
- () => {
124
- it("should be valid",
125
- () => {
126
- expect(isValidBankAccount(iban)).toBe(valid);
127
- });
128
- })
129
- ));