@experium/findy-form 1.2.6 → 1.2.15
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/Jenkinsfile +5 -1
- package/dist/app.js +10 -10
- package/lib/components/formComponents/HtmlOpdForm.js +3 -3
- package/lib/components/formComponents/PersonalDataAgreement.js +13 -8
- package/lib/constants/translations.js +27 -18
- package/lib/utils/validation.js +39 -3
- package/package.json +3 -5
- package/src/components/formComponents/HtmlOpdForm.js +3 -7
- package/src/components/formComponents/PersonalDataAgreement.js +12 -8
- package/src/constants/translations.js +27 -18
- package/src/utils/validation.js +39 -5
|
@@ -77,7 +77,7 @@ var styles = {
|
|
|
77
77
|
var commonStyle = "\n .opd-html-form {\n line-height: 20px;\n }\n .opd-html-form input {\n border: none;\n border-bottom: 1px solid #000;\n font-size: 16px;\n pointer-events: auto;\n }\n .opd-html-form label {\n pointer-events: auto;\n }\n .opd-html-form input:focus {\n outline: none;\n }\n .opd-html-form.submitted input:invalid {\n border-bottom: 1px solid red;\n }\n .opd-html-form input[type=\"checkbox\"] {\n position: relative;\n margin-right: 10px;\n }\n .opd-html-form input[type=\"checkbox\"]:required::after {\n content: \"*\";\n color: red;\n top: -6px;\n right: -8px;\n position: absolute;\n }\n .opd-html-form.submitted input[type=\"checkbox\"]:invalid {\n outline: 1px solid red;\n }\n";
|
|
78
78
|
|
|
79
79
|
var getHtml = function getHtml(body) {
|
|
80
|
-
return "\n <!DOCTYPE html>\n <html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <title>OPD</title>\n <style>\n ".concat(commonStyle, "\n .opd-html-form {\n font-family: Arial;\n font-size: 16px;\n }\n .opd-html-form input,\n .opd-html-form label {\n pointer-events: none;\n }\n .opd-html-form input[type=\"checkbox\"]:required::after {\n content: \"\";\n }\n
|
|
80
|
+
return "\n <!DOCTYPE html>\n <html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <title>OPD</title>\n <style>\n ".concat(commonStyle, "\n .opd-html-form {\n font-family: Arial;\n font-size: 16px;\n }\n .opd-html-form input,\n .opd-html-form label {\n pointer-events: none;\n }\n .opd-html-form input[type=\"checkbox\"]:required::after {\n content: \"\";\n }\n </style>\n </head>\n <body>\n <div style=\"margin: 10px auto; max-width: 1080px;\">\n ").concat(body, "\n </div>\n </body>\n </html>\n");
|
|
81
81
|
};
|
|
82
82
|
|
|
83
83
|
exports.getHtml = getHtml;
|
|
@@ -241,13 +241,13 @@ var HtmlOpdForm = /*#__PURE__*/function (_Component) {
|
|
|
241
241
|
dangerouslySetInnerHTML: {
|
|
242
242
|
__html: html
|
|
243
243
|
}
|
|
244
|
-
}), /*#__PURE__*/_react["default"].createElement("button", (0, _extends2["default"])({
|
|
244
|
+
})), /*#__PURE__*/_react["default"].createElement("button", (0, _extends2["default"])({
|
|
245
245
|
className: "".concat(styles.formBtn, " form-button"),
|
|
246
246
|
type: "button",
|
|
247
247
|
onClick: function onClick() {
|
|
248
248
|
return _this2.onSubmit(formProps);
|
|
249
249
|
}
|
|
250
|
-
}, (0, _attrs.getAttrs)('opdAccept', htmlAttrs)), acceptBtn || t('opdFormAccept'))))
|
|
250
|
+
}, (0, _attrs.getAttrs)('opdAccept', htmlAttrs)), acceptBtn || t('opdFormAccept'))));
|
|
251
251
|
}
|
|
252
252
|
}]);
|
|
253
253
|
return HtmlOpdForm;
|
|
@@ -83,24 +83,29 @@ var styles = {
|
|
|
83
83
|
|
|
84
84
|
var getConstructorOpd = function getConstructorOpd(opdSettings, language) {
|
|
85
85
|
var opdConstructor = language && language !== 'ru' ? (0, _ramda.pathOr)([], ['data', 'locale', language, 'opdConstructor'], opdSettings) : (0, _ramda.pathOr)([], ['data', 'opdConstructor'], opdSettings);
|
|
86
|
-
var
|
|
87
|
-
var text = opdConstructor.reduce(function (res, cur) {
|
|
86
|
+
var text = (opdConstructor || []).reduce(function (res, cur) {
|
|
88
87
|
switch (cur.type) {
|
|
89
88
|
case 'question':
|
|
90
89
|
return "".concat(res, "<input name=\"").concat(cur.question, "\" placeholder=\"").concat(cur.placeholder || '', "\" type=\"text\" ").concat(cur.required ? 'required' : '', " /> ");
|
|
91
90
|
|
|
92
91
|
case 'formated':
|
|
93
|
-
return res + cur.text;
|
|
92
|
+
return res + (cur.text || '');
|
|
93
|
+
|
|
94
|
+
case 'checkbox':
|
|
95
|
+
return "".concat(res, "<p>\n <input type=\"checkbox\" id=\"", "checkbox-".concat(cur.id), "\" />\n <label htmlFor=\"", "checkbox-".concat(cur.id), "\">").concat(cur.required ? /*#__PURE__*/_react["default"].createElement("span", {
|
|
96
|
+
style: {
|
|
97
|
+
color: 'red'
|
|
98
|
+
}
|
|
99
|
+
}, "* ") : '').concat(cur.label || '', "</label>\n </p>");
|
|
100
|
+
|
|
101
|
+
case 'opdCheckbox':
|
|
102
|
+
return "".concat(res, "<p>\n <input type=\"checkbox\" id=\"").concat(cur.opdType, "\" />\n <label htmlFor=\"").concat(cur.opdType, "\">").concat((0, _ramda.path)([cur.opdType, 'required'], opdSettings) ? '<span style="color: red;">* </span>' : '').concat((0, _ramda.pathOr)('', [cur.opdType, 'label'], opdSettings), "</label>\n </p>");
|
|
94
103
|
|
|
95
104
|
default:
|
|
96
105
|
return res;
|
|
97
106
|
}
|
|
98
107
|
}, '');
|
|
99
|
-
return "<div>\n ".concat(text, "\n
|
|
100
|
-
return !!i.show;
|
|
101
|
-
}, checkboxes).reduce(function (res, cur, index) {
|
|
102
|
-
return "".concat(res, "<p><label><input name=\"checkbox-").concat(index, "\" type=\"checkbox\" ").concat(cur.required ? 'required' : '', " />").concat(cur.label, "</label></p>");
|
|
103
|
-
}, ''), "\n </div>");
|
|
108
|
+
return "<div>\n ".concat(text, "\n </div>");
|
|
104
109
|
};
|
|
105
110
|
|
|
106
111
|
var PersonalDataAgreementComponent = /*#__PURE__*/function (_Component) {
|
|
@@ -94,8 +94,9 @@ var TRANSLATIONS = {
|
|
|
94
94
|
'fileTypeAudio': 'Invalid type, select audio file',
|
|
95
95
|
'fileTypeVideo': 'Invalid type, select video file',
|
|
96
96
|
'composite': 'Required block',
|
|
97
|
-
'
|
|
98
|
-
'captchaRequired': 'Verification required'
|
|
97
|
+
'incompleteDate': 'Full date is required',
|
|
98
|
+
'captchaRequired': 'Verification required',
|
|
99
|
+
'incorrectBirthDate': 'Date in "Education" or "Experience" blocks cant be earlier then birth date'
|
|
99
100
|
},
|
|
100
101
|
'invalidCaptcha': 'Invalid captcha'
|
|
101
102
|
}
|
|
@@ -188,8 +189,9 @@ var TRANSLATIONS = {
|
|
|
188
189
|
'fileTypeAudio': 'Неверный тип файла, выберите аудиофайл',
|
|
189
190
|
'fileTypeVideo': 'Неверный тип файла, выберите видеофайл',
|
|
190
191
|
'composite': 'Блок обязателен для заполнения',
|
|
191
|
-
'
|
|
192
|
-
'captchaRequired': 'Необходимо пройти проверку'
|
|
192
|
+
'incompleteDate': 'Необходимо указать дату полностью',
|
|
193
|
+
'captchaRequired': 'Необходимо пройти проверку',
|
|
194
|
+
'incorrectBirthDate': 'Дата в блоках "Образование" и "Опыт работы" не может быть раньше, чем дата рождения'
|
|
193
195
|
},
|
|
194
196
|
'invalidCaptcha': 'Неверно введена капча'
|
|
195
197
|
}
|
|
@@ -282,8 +284,9 @@ var TRANSLATIONS = {
|
|
|
282
284
|
'fileTypeAudio': 'Неправильний тип файлу, виберіть аудіофайл',
|
|
283
285
|
'fileTypeVideo': 'Невірний тип файлу, виберіть відеофайл',
|
|
284
286
|
'composite': 'Блок обов\'язковий для заповнення',
|
|
285
|
-
'
|
|
286
|
-
'captchaRequired': 'Необхідно пройти перевірку'
|
|
287
|
+
'incompleteDate': 'Необхідно вказати дату повністю',
|
|
288
|
+
'captchaRequired': 'Необхідно пройти перевірку',
|
|
289
|
+
'incorrectBirthDate': 'Date in "Education" or "Experience" blocks cant be earlier then birth date'
|
|
287
290
|
},
|
|
288
291
|
'invalidCaptcha': 'Невірно введена капча'
|
|
289
292
|
}
|
|
@@ -375,8 +378,9 @@ var TRANSLATIONS = {
|
|
|
375
378
|
'fileTypeAudio': 'Vale tüüp, valige helifail',
|
|
376
379
|
'fileTypeVideo': 'Vale tüüp, valige videofail',
|
|
377
380
|
'composite': 'Nõutav plokk',
|
|
378
|
-
'
|
|
379
|
-
'captchaRequired': 'Nõutav kontrollimine'
|
|
381
|
+
'incompleteDate': 'Täiskuupäev on kohustuslik',
|
|
382
|
+
'captchaRequired': 'Nõutav kontrollimine',
|
|
383
|
+
'incorrectBirthDate': 'Date in "Education" or "Experience" blocks cant be earlier then birth date'
|
|
380
384
|
},
|
|
381
385
|
'invalidCaptcha': 'Sisestati sobimatu captcha'
|
|
382
386
|
}
|
|
@@ -468,8 +472,9 @@ var TRANSLATIONS = {
|
|
|
468
472
|
'fileTypeAudio': 'Nederīgs tips, atlasiet audio failu',
|
|
469
473
|
'fileTypeVideo': 'Nederīgs tips, atlasiet video failu',
|
|
470
474
|
'composite': 'Nepieciešamais bloks',
|
|
471
|
-
'
|
|
472
|
-
'captchaRequired': 'Nepieciešama verifikācija'
|
|
475
|
+
'incompleteDate': 'Nepieciešams norādīt pilnu datumu',
|
|
476
|
+
'captchaRequired': 'Nepieciešama verifikācija',
|
|
477
|
+
'incorrectBirthDate': 'Date in "Education" or "Experience" blocks cant be earlier then birth date'
|
|
473
478
|
},
|
|
474
479
|
'invalidCaptcha': 'Ievadīta nederīga captcha'
|
|
475
480
|
}
|
|
@@ -561,8 +566,9 @@ var TRANSLATIONS = {
|
|
|
561
566
|
'fileTypeAudio': 'Netinkamas tipas, pasirinkite garso failą',
|
|
562
567
|
'fileTypeVideo': 'Netinkamas tipas, pasirinkite vaizdo failą',
|
|
563
568
|
'composite': 'Reikalingas blokas',
|
|
564
|
-
'
|
|
565
|
-
'captchaRequired': 'Būtina patvirtinti'
|
|
569
|
+
'incompleteDate': 'Būtina nurodyti visą datą',
|
|
570
|
+
'captchaRequired': 'Būtina patvirtinti',
|
|
571
|
+
'incorrectBirthDate': 'Date in "Education" or "Experience" blocks cant be earlier then birth date'
|
|
566
572
|
},
|
|
567
573
|
'invalidCaptcha': 'Įvesta netinkama captcha'
|
|
568
574
|
}
|
|
@@ -655,8 +661,9 @@ var TRANSLATIONS = {
|
|
|
655
661
|
'fileTypeAudio': 'Файл түрі жарамсыз, аудио файлды таңдаңыз',
|
|
656
662
|
'fileTypeVideo': 'Файл түрі жарамсыз, бейне файлды таңдаңыз',
|
|
657
663
|
'composite': 'Блок қажет',
|
|
658
|
-
'
|
|
659
|
-
'captchaRequired': 'Тексеру қажет'
|
|
664
|
+
'incompleteDate': 'Сіз толық күнді көрсетуіңіз керек',
|
|
665
|
+
'captchaRequired': 'Тексеру қажет',
|
|
666
|
+
'incorrectBirthDate': 'Date in "Education" or "Experience" blocks cant be earlier then birth date'
|
|
660
667
|
},
|
|
661
668
|
'invalidCaptcha': 'Жарамсыз captcha енгізілді'
|
|
662
669
|
}
|
|
@@ -749,8 +756,9 @@ var TRANSLATIONS = {
|
|
|
749
756
|
'fileTypeAudio': 'ประเภทไฟล์ไม่ถูกต้อง เลือกไฟล์เสียง',
|
|
750
757
|
'fileTypeVideo': 'ประเภทไฟล์ไม่ถูกต้อง เลือกไฟล์วิดีโอ',
|
|
751
758
|
'composite': 'จำเป็นต้องบล็อก',
|
|
752
|
-
'
|
|
753
|
-
'captchaRequired': 'ต้องยืนยัน'
|
|
759
|
+
'incompleteDate': 'คุณต้องระบุวันที่แบบเต็ม',
|
|
760
|
+
'captchaRequired': 'ต้องยืนยัน',
|
|
761
|
+
'incorrectBirthDate': 'Date in "Education" or "Experience" blocks cant be earlier then birth date'
|
|
754
762
|
},
|
|
755
763
|
'validCaptcha': 'ป้อน captcha ไม่ถูกต้อง'
|
|
756
764
|
}
|
|
@@ -843,8 +851,9 @@ var TRANSLATIONS = {
|
|
|
843
851
|
'fileTypeAudio': 'Fayl turi noto\'g\'ri, audio faylni tanlang',
|
|
844
852
|
'fileTypeVideo': 'Fayl turi noto\'g\'ri, video faylni tanlang',
|
|
845
853
|
'composite': 'Bloklash shart',
|
|
846
|
-
'
|
|
847
|
-
'captchaRequired': 'Tasdiqlash kerak'
|
|
854
|
+
'incompleteDate': 'To\'liq sanani ko\'rsatish kerak',
|
|
855
|
+
'captchaRequired': 'Tasdiqlash kerak',
|
|
856
|
+
'incorrectBirthDate': 'Date in "Education" or "Experience" blocks cant be earlier then birth date'
|
|
848
857
|
},
|
|
849
858
|
'invalidCaptcha': "Noto'g'ri captcha kiritildi"
|
|
850
859
|
}
|
package/lib/utils/validation.js
CHANGED
|
@@ -13,6 +13,8 @@ var _ramda = require("ramda");
|
|
|
13
13
|
|
|
14
14
|
var yup = _interopRequireWildcard(require("yup"));
|
|
15
15
|
|
|
16
|
+
var _moment = _interopRequireDefault(require("moment"));
|
|
17
|
+
|
|
16
18
|
var _classValidator = require("class-validator");
|
|
17
19
|
|
|
18
20
|
var _libphonenumberJs = require("libphonenumber-js");
|
|
@@ -273,16 +275,50 @@ var rules = {
|
|
|
273
275
|
date: function date() {
|
|
274
276
|
return yup.string().nullable().test({
|
|
275
277
|
name: 'completeDate',
|
|
276
|
-
message: _i18n["default"].t('errors.
|
|
278
|
+
message: _i18n["default"].t('errors.incompleteDate'),
|
|
277
279
|
test: function test(value) {
|
|
278
280
|
return value !== 'incomplete';
|
|
279
281
|
}
|
|
280
282
|
});
|
|
281
283
|
}
|
|
282
284
|
};
|
|
285
|
+
var incorrectBirthDateLinked = {
|
|
286
|
+
experience: ['experienceStart', 'experienceEnd'],
|
|
287
|
+
courses: ['courseYearEnd'],
|
|
288
|
+
education: ['yearEnd']
|
|
289
|
+
};
|
|
290
|
+
var additionalRules = {
|
|
291
|
+
birthDate: function birthDate(rule, form) {
|
|
292
|
+
return rule.test({
|
|
293
|
+
name: 'incorrectBirthDate',
|
|
294
|
+
message: _i18n["default"].t('errors.incorrectBirthDate'),
|
|
295
|
+
test: function test(value) {
|
|
296
|
+
if (!value || value === 'incomplete') {
|
|
297
|
+
return true;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
var date = (0, _moment["default"])(value, 'DD.MM.YYYY');
|
|
301
|
+
var valid = true;
|
|
302
|
+
(0, _ramda.forEach)(function (block) {
|
|
303
|
+
if (form[block]) {
|
|
304
|
+
(0, _ramda.forEach)(function (blockItem) {
|
|
305
|
+
(0, _ramda.forEach)(function (linkedField) {
|
|
306
|
+
if (blockItem[linkedField]) {
|
|
307
|
+
var linkedDate = (0, _moment["default"])(blockItem[linkedField], block === 'experience' ? 'MM.YYYY' : 'YYYY');
|
|
308
|
+
valid = valid ? linkedDate.isAfter(date) : valid;
|
|
309
|
+
}
|
|
310
|
+
}, incorrectBirthDateLinked[block]);
|
|
311
|
+
}, form[block]);
|
|
312
|
+
}
|
|
313
|
+
}, (0, _ramda.keys)(incorrectBirthDateLinked));
|
|
314
|
+
return valid;
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
};
|
|
283
319
|
|
|
284
320
|
var validate = function validate(value, form, field, fieldsWithoutValidation, props) {
|
|
285
|
-
var customValidation = (0, _ramda.path)(['customValidation', field.field], props);
|
|
321
|
+
var customValidation = (0, _ramda.path)(['customValidation', field.field], props) || (0, _ramda.path)([field.field], additionalRules);
|
|
286
322
|
|
|
287
323
|
try {
|
|
288
324
|
var rule = rules[field.type] ? rules[field.type](field, props) : yup.string();
|
|
@@ -291,7 +327,7 @@ var validate = function validate(value, form, field, fieldsWithoutValidation, pr
|
|
|
291
327
|
}) : (field.required || validateLink(field, form)) && !fieldsWithoutValidation[field.field] ? rule.nullable().required(function () {
|
|
292
328
|
return _i18n["default"].t('errors.required');
|
|
293
329
|
}) : rule.nullable();
|
|
294
|
-
rule = customValidation ? customValidation(rule) : rule;
|
|
330
|
+
rule = customValidation ? customValidation(rule, form) : rule;
|
|
295
331
|
rule.validateSync(value);
|
|
296
332
|
return undefined;
|
|
297
333
|
} catch (e) {
|
package/package.json
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@experium/findy-form",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.15",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
"url": "https://github.com/experium/findy-form.git"
|
|
8
|
-
},
|
|
5
|
+
"homepage": "https://experium.github.io/findy-form",
|
|
6
|
+
"repository": "https://github.com/experium/findy-form",
|
|
9
7
|
"publishConfig": {
|
|
10
8
|
"access": "public",
|
|
11
9
|
"cache": "~/.npm"
|
|
@@ -63,9 +63,6 @@ export const getHtml = body => `
|
|
|
63
63
|
.opd-html-form input[type="checkbox"]:required::after {
|
|
64
64
|
content: "";
|
|
65
65
|
}
|
|
66
|
-
.form-button {
|
|
67
|
-
display: none;
|
|
68
|
-
}
|
|
69
66
|
</style>
|
|
70
67
|
</head>
|
|
71
68
|
<body>
|
|
@@ -178,11 +175,10 @@ class HtmlOpdForm extends Component {
|
|
|
178
175
|
</button>
|
|
179
176
|
|
|
180
177
|
<div className={cx('opd-html-form', { submitted: this.state.submitted })} dangerouslySetInnerHTML={{ __html: html }} />
|
|
181
|
-
|
|
182
|
-
<button className={`${styles.formBtn} form-button`} type='button' onClick={() => this.onSubmit(formProps)} {...getAttrs('opdAccept', htmlAttrs)}>
|
|
183
|
-
{ acceptBtn || t('opdFormAccept') }
|
|
184
|
-
</button>
|
|
185
178
|
</form>
|
|
179
|
+
<button className={`${styles.formBtn} form-button`} type='button' onClick={() => this.onSubmit(formProps)} {...getAttrs('opdAccept', htmlAttrs)}>
|
|
180
|
+
{ acceptBtn || t('opdFormAccept') }
|
|
181
|
+
</button>
|
|
186
182
|
</div>
|
|
187
183
|
</Fragment>;
|
|
188
184
|
}
|
|
@@ -15,14 +15,23 @@ import { getAttrs } from '../../utils/attrs';
|
|
|
15
15
|
|
|
16
16
|
const getConstructorOpd = (opdSettings, language) => {
|
|
17
17
|
const opdConstructor = language && language !== 'ru' ? pathOr([], ['data', 'locale', language, 'opdConstructor'], opdSettings) : pathOr([], ['data', 'opdConstructor'], opdSettings);
|
|
18
|
-
const checkboxes = language && language !== 'ru' ? pathOr([], ['data', 'locale', language, 'checkboxes'], opdSettings) : pathOr([], ['data', 'checkboxes'], opdSettings);
|
|
19
18
|
|
|
20
|
-
const text = opdConstructor.reduce((res, cur) => {
|
|
19
|
+
const text = (opdConstructor || []).reduce((res, cur) => {
|
|
21
20
|
switch (cur.type) {
|
|
22
21
|
case 'question':
|
|
23
22
|
return `${res}<input name="${cur.question}" placeholder="${cur.placeholder || ''}" type="text" ${cur.required ? 'required' : ''} /> `;
|
|
24
23
|
case 'formated':
|
|
25
|
-
return res + cur.text;
|
|
24
|
+
return res + (cur.text || '');
|
|
25
|
+
case 'checkbox':
|
|
26
|
+
return `${res}<p>
|
|
27
|
+
<input type="checkbox" id="${`checkbox-${cur.id}`}" />
|
|
28
|
+
<label htmlFor="${`checkbox-${cur.id}`}">${cur.required ? <span style={{ color: 'red' }}>* </span> : ''}${cur.label || ''}</label>
|
|
29
|
+
</p>`;
|
|
30
|
+
case 'opdCheckbox':
|
|
31
|
+
return `${res}<p>
|
|
32
|
+
<input type="checkbox" id="${cur.opdType}" />
|
|
33
|
+
<label htmlFor="${cur.opdType}">${path([cur.opdType, 'required'], opdSettings) ? '<span style="color: red;">* </span>' : ''}${pathOr('', [cur.opdType, 'label'], opdSettings)}</label>
|
|
34
|
+
</p>`;
|
|
26
35
|
default:
|
|
27
36
|
return res;
|
|
28
37
|
}
|
|
@@ -30,11 +39,6 @@ const getConstructorOpd = (opdSettings, language) => {
|
|
|
30
39
|
|
|
31
40
|
return `<div>
|
|
32
41
|
${text}
|
|
33
|
-
${path(['purposeCheckbox', 'active'], opdSettings) ? `<p><label><input name="opdPurpose" type="checkbox" data-separate-field="opdPurpose" ${path(['purposeCheckbox', 'required'], opdSettings) ? 'required' : ''} />${path(['purposeCheckbox', 'label'], opdSettings)}</label></p>` : ''}
|
|
34
|
-
${path(['acceptCheckbox', 'active'], opdSettings) ? `<p><label><input name="opdAccept" type="checkbox" data-separate-field="opdAccept" ${path(['acceptCheckbox', 'required'], opdSettings) ? 'required' : ''} />${path(['acceptCheckbox', 'label'], opdSettings)}</label></p>` : ''}
|
|
35
|
-
${path(['transmissionCheckbox', 'active'], opdSettings) ? `<p><label><input name="transmission" type="checkbox" data-separate-field="transmission" ${path(['transmissionCheckbox', 'required'], opdSettings) ? 'required' : ''} />${path(['transmissionCheckbox', 'label'], opdSettings)}</label></p>` : ''}
|
|
36
|
-
${path(['mailingCheckbox', 'active'], opdSettings) ? `<p><label><input name="mailing" type="checkbox" data-separate-field="mailing" ${path(['mailingCheckbox', 'required'], opdSettings) ? 'required' : ''} />${path(['mailingCheckbox', 'label'], opdSettings)}</label></p>` : ''}
|
|
37
|
-
${filter(i => !!i.show, checkboxes).reduce((res, cur, index) => `${res}<p><label><input name="checkbox-${index}" type="checkbox" ${cur.required ? 'required' : ''} />${cur.label}</label></p>`, '')}
|
|
38
42
|
</div>`;
|
|
39
43
|
};
|
|
40
44
|
|
|
@@ -64,8 +64,9 @@ export const TRANSLATIONS = {
|
|
|
64
64
|
'fileTypeAudio': 'Invalid type, select audio file',
|
|
65
65
|
'fileTypeVideo': 'Invalid type, select video file',
|
|
66
66
|
'composite': 'Required block',
|
|
67
|
-
'
|
|
68
|
-
'captchaRequired': 'Verification required'
|
|
67
|
+
'incompleteDate': 'Full date is required',
|
|
68
|
+
'captchaRequired': 'Verification required',
|
|
69
|
+
'incorrectBirthDate': 'Date in "Education" or "Experience" blocks cant be earlier then birth date',
|
|
69
70
|
},
|
|
70
71
|
'invalidCaptcha': 'Invalid captcha'
|
|
71
72
|
},
|
|
@@ -135,8 +136,9 @@ export const TRANSLATIONS = {
|
|
|
135
136
|
'fileTypeAudio': 'Неверный тип файла, выберите аудиофайл',
|
|
136
137
|
'fileTypeVideo': 'Неверный тип файла, выберите видеофайл',
|
|
137
138
|
'composite': 'Блок обязателен для заполнения',
|
|
138
|
-
'
|
|
139
|
-
'captchaRequired': 'Необходимо пройти проверку'
|
|
139
|
+
'incompleteDate': 'Необходимо указать дату полностью',
|
|
140
|
+
'captchaRequired': 'Необходимо пройти проверку',
|
|
141
|
+
'incorrectBirthDate': 'Дата в блоках "Образование" и "Опыт работы" не может быть раньше, чем дата рождения',
|
|
140
142
|
},
|
|
141
143
|
'invalidCaptcha': 'Неверно введена капча'
|
|
142
144
|
},
|
|
@@ -206,8 +208,9 @@ export const TRANSLATIONS = {
|
|
|
206
208
|
'fileTypeAudio': 'Неправильний тип файлу, виберіть аудіофайл',
|
|
207
209
|
'fileTypeVideo': 'Невірний тип файлу, виберіть відеофайл',
|
|
208
210
|
'composite': 'Блок обов\'язковий для заповнення',
|
|
209
|
-
'
|
|
210
|
-
'captchaRequired': 'Необхідно пройти перевірку'
|
|
211
|
+
'incompleteDate': 'Необхідно вказати дату повністю',
|
|
212
|
+
'captchaRequired': 'Необхідно пройти перевірку',
|
|
213
|
+
'incorrectBirthDate': 'Date in "Education" or "Experience" blocks cant be earlier then birth date',
|
|
211
214
|
},
|
|
212
215
|
'invalidCaptcha': 'Невірно введена капча'
|
|
213
216
|
},
|
|
@@ -276,8 +279,9 @@ export const TRANSLATIONS = {
|
|
|
276
279
|
'fileTypeAudio': 'Vale tüüp, valige helifail',
|
|
277
280
|
'fileTypeVideo': 'Vale tüüp, valige videofail',
|
|
278
281
|
'composite': 'Nõutav plokk',
|
|
279
|
-
'
|
|
280
|
-
'captchaRequired': 'Nõutav kontrollimine'
|
|
282
|
+
'incompleteDate': 'Täiskuupäev on kohustuslik',
|
|
283
|
+
'captchaRequired': 'Nõutav kontrollimine',
|
|
284
|
+
'incorrectBirthDate': 'Date in "Education" or "Experience" blocks cant be earlier then birth date',
|
|
281
285
|
},
|
|
282
286
|
'invalidCaptcha': 'Sisestati sobimatu captcha'
|
|
283
287
|
},
|
|
@@ -346,8 +350,9 @@ export const TRANSLATIONS = {
|
|
|
346
350
|
'fileTypeAudio': 'Nederīgs tips, atlasiet audio failu',
|
|
347
351
|
'fileTypeVideo': 'Nederīgs tips, atlasiet video failu',
|
|
348
352
|
'composite': 'Nepieciešamais bloks',
|
|
349
|
-
'
|
|
350
|
-
'captchaRequired': 'Nepieciešama verifikācija'
|
|
353
|
+
'incompleteDate': 'Nepieciešams norādīt pilnu datumu',
|
|
354
|
+
'captchaRequired': 'Nepieciešama verifikācija',
|
|
355
|
+
'incorrectBirthDate': 'Date in "Education" or "Experience" blocks cant be earlier then birth date',
|
|
351
356
|
},
|
|
352
357
|
'invalidCaptcha': 'Ievadīta nederīga captcha'
|
|
353
358
|
},
|
|
@@ -416,8 +421,9 @@ export const TRANSLATIONS = {
|
|
|
416
421
|
'fileTypeAudio': 'Netinkamas tipas, pasirinkite garso failą',
|
|
417
422
|
'fileTypeVideo': 'Netinkamas tipas, pasirinkite vaizdo failą',
|
|
418
423
|
'composite': 'Reikalingas blokas',
|
|
419
|
-
'
|
|
420
|
-
'captchaRequired': 'Būtina patvirtinti'
|
|
424
|
+
'incompleteDate': 'Būtina nurodyti visą datą',
|
|
425
|
+
'captchaRequired': 'Būtina patvirtinti',
|
|
426
|
+
'incorrectBirthDate': 'Date in "Education" or "Experience" blocks cant be earlier then birth date',
|
|
421
427
|
},
|
|
422
428
|
'invalidCaptcha': 'Įvesta netinkama captcha'
|
|
423
429
|
},
|
|
@@ -487,8 +493,9 @@ export const TRANSLATIONS = {
|
|
|
487
493
|
'fileTypeAudio': 'Файл түрі жарамсыз, аудио файлды таңдаңыз',
|
|
488
494
|
'fileTypeVideo': 'Файл түрі жарамсыз, бейне файлды таңдаңыз',
|
|
489
495
|
'composite': 'Блок қажет',
|
|
490
|
-
'
|
|
491
|
-
'captchaRequired': 'Тексеру қажет'
|
|
496
|
+
'incompleteDate': 'Сіз толық күнді көрсетуіңіз керек',
|
|
497
|
+
'captchaRequired': 'Тексеру қажет',
|
|
498
|
+
'incorrectBirthDate': 'Date in "Education" or "Experience" blocks cant be earlier then birth date',
|
|
492
499
|
},
|
|
493
500
|
'invalidCaptcha': 'Жарамсыз captcha енгізілді'
|
|
494
501
|
},
|
|
@@ -558,8 +565,9 @@ export const TRANSLATIONS = {
|
|
|
558
565
|
'fileTypeAudio': 'ประเภทไฟล์ไม่ถูกต้อง เลือกไฟล์เสียง',
|
|
559
566
|
'fileTypeVideo': 'ประเภทไฟล์ไม่ถูกต้อง เลือกไฟล์วิดีโอ',
|
|
560
567
|
'composite': 'จำเป็นต้องบล็อก',
|
|
561
|
-
'
|
|
562
|
-
'captchaRequired': 'ต้องยืนยัน'
|
|
568
|
+
'incompleteDate': 'คุณต้องระบุวันที่แบบเต็ม',
|
|
569
|
+
'captchaRequired': 'ต้องยืนยัน',
|
|
570
|
+
'incorrectBirthDate': 'Date in "Education" or "Experience" blocks cant be earlier then birth date',
|
|
563
571
|
},
|
|
564
572
|
'validCaptcha': 'ป้อน captcha ไม่ถูกต้อง'
|
|
565
573
|
},
|
|
@@ -629,8 +637,9 @@ export const TRANSLATIONS = {
|
|
|
629
637
|
'fileTypeAudio': 'Fayl turi noto\'g\'ri, audio faylni tanlang',
|
|
630
638
|
'fileTypeVideo': 'Fayl turi noto\'g\'ri, video faylni tanlang',
|
|
631
639
|
'composite': 'Bloklash shart',
|
|
632
|
-
'
|
|
633
|
-
'captchaRequired': 'Tasdiqlash kerak'
|
|
640
|
+
'incompleteDate': 'To\'liq sanani ko\'rsatish kerak',
|
|
641
|
+
'captchaRequired': 'Tasdiqlash kerak',
|
|
642
|
+
'incorrectBirthDate': 'Date in "Education" or "Experience" blocks cant be earlier then birth date',
|
|
634
643
|
},
|
|
635
644
|
'invalidCaptcha': "Noto'g'ri captcha kiritildi"
|
|
636
645
|
},
|
package/src/utils/validation.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { path, split, replace, contains, head, prop, isEmpty, values, join, keys, startsWith, is } from 'ramda';
|
|
1
|
+
import { path, split, replace, contains, head, prop, isEmpty, values, join, keys, startsWith, is, forEach } from 'ramda';
|
|
2
2
|
import * as yup from 'yup';
|
|
3
|
+
import moment from 'moment';
|
|
3
4
|
import { isPhoneNumber } from 'class-validator';
|
|
4
5
|
import { parsePhoneNumberWithError, ParseError } from 'libphonenumber-js';
|
|
5
6
|
|
|
@@ -211,20 +212,53 @@ const rules = {
|
|
|
211
212
|
}),
|
|
212
213
|
date: () => yup.string().nullable().test({
|
|
213
214
|
name: 'completeDate',
|
|
214
|
-
message: i18n.t('errors.
|
|
215
|
+
message: i18n.t('errors.incompleteDate'),
|
|
215
216
|
test: value => value !== 'incomplete'
|
|
216
|
-
})
|
|
217
|
+
}),
|
|
218
|
+
};
|
|
219
|
+
const incorrectBirthDateLinked = {
|
|
220
|
+
experience: ['experienceStart', 'experienceEnd'],
|
|
221
|
+
courses: ['courseYearEnd'],
|
|
222
|
+
education: ['yearEnd'],
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
const additionalRules = {
|
|
226
|
+
birthDate: (rule, form) => rule.test({
|
|
227
|
+
name: 'incorrectBirthDate',
|
|
228
|
+
message: i18n.t('errors.incorrectBirthDate'),
|
|
229
|
+
test: value => {
|
|
230
|
+
if (!value || value === 'incomplete') {
|
|
231
|
+
return true;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
const date = moment(value, 'DD.MM.YYYY');
|
|
235
|
+
let valid = true;
|
|
236
|
+
forEach(block => {
|
|
237
|
+
if (form[block]) {
|
|
238
|
+
forEach(blockItem => {
|
|
239
|
+
forEach(linkedField => {
|
|
240
|
+
if (blockItem[linkedField]) {
|
|
241
|
+
const linkedDate = moment(blockItem[linkedField], block === 'experience' ? 'MM.YYYY' : 'YYYY');
|
|
242
|
+
valid = valid ? linkedDate.isAfter(date) : valid;
|
|
243
|
+
}
|
|
244
|
+
}, incorrectBirthDateLinked[block]);
|
|
245
|
+
}, form[block]);
|
|
246
|
+
}
|
|
247
|
+
}, keys(incorrectBirthDateLinked));
|
|
248
|
+
return valid;
|
|
249
|
+
}
|
|
250
|
+
}),
|
|
217
251
|
};
|
|
218
252
|
|
|
219
253
|
export const validate = (value, form, field, fieldsWithoutValidation, props) => {
|
|
220
|
-
const customValidation = path(['customValidation', field.field], props);
|
|
254
|
+
const customValidation = path(['customValidation', field.field], props) || path([field.field], additionalRules);
|
|
221
255
|
|
|
222
256
|
try {
|
|
223
257
|
let rule = rules[field.type] ? rules[field.type](field, props) : yup.string();
|
|
224
258
|
rule = (field.type === 'personalDataAgreement') ? rule.nullable().required(() => i18n.t('errors.required')) : (
|
|
225
259
|
(field.required || validateLink(field, form)) && !fieldsWithoutValidation[field.field] ? rule.nullable().required(() => i18n.t('errors.required')) : rule.nullable()
|
|
226
260
|
);
|
|
227
|
-
rule = customValidation ? customValidation(rule) : rule;
|
|
261
|
+
rule = customValidation ? customValidation(rule, form) : rule;
|
|
228
262
|
|
|
229
263
|
rule.validateSync(value);
|
|
230
264
|
return undefined;
|