nox-validation 1.6.5 → 1.6.7
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/lib/validate.js +35 -27
- package/package.json +1 -1
package/lib/validate.js
CHANGED
|
@@ -430,31 +430,34 @@ const validateMetaRules = (
|
|
|
430
430
|
}
|
|
431
431
|
|
|
432
432
|
if (
|
|
433
|
-
(
|
|
434
|
-
required
|
|
433
|
+
(!field?.meta?.hidden &&
|
|
434
|
+
// Not relational, required, and empty
|
|
435
|
+
((isEmpty(fieldValue) &&
|
|
436
|
+
required &&
|
|
437
|
+
![
|
|
438
|
+
constants.interfaces.FILES,
|
|
439
|
+
constants.interfaces.FILE,
|
|
440
|
+
constants.interfaces.FILE_IMAGE,
|
|
441
|
+
constants.interfaces.MANY_TO_MANY,
|
|
442
|
+
constants.interfaces.ONE_TO_MANY,
|
|
443
|
+
constants.interfaces.MANY_TO_ONE,
|
|
444
|
+
constants.interfaces.MANY_TO_ANY,
|
|
445
|
+
"none",
|
|
446
|
+
].includes(field?.meta?.interface)) ||
|
|
447
|
+
// Translations interface needs to be handled
|
|
448
|
+
(field?.meta?.interface === constants.interfaces.TRANSLATIONS &&
|
|
449
|
+
language_codes?.length &&
|
|
450
|
+
!onlyFormFields) ||
|
|
451
|
+
// OBJECT or ITEMS interfaces
|
|
452
|
+
((field?.meta?.interface === constants.interfaces.OBJECT ||
|
|
453
|
+
field?.meta?.interface === constants.interfaces.ITEMS) &&
|
|
454
|
+
!onlyFormFields &&
|
|
455
|
+
getNodes))) ||
|
|
456
|
+
// SEO interface: onlyFormFields, is empty in existingForm, getNodes, and not hidden
|
|
457
|
+
(field?.meta?.interface === constants.interfaces.SEO &&
|
|
435
458
|
!field?.meta?.hidden &&
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
constants.interfaces.FILE,
|
|
439
|
-
constants.interfaces.FILE_IMAGE,
|
|
440
|
-
constants.interfaces.MANY_TO_MANY,
|
|
441
|
-
constants.interfaces.ONE_TO_MANY,
|
|
442
|
-
constants.interfaces.MANY_TO_ONE,
|
|
443
|
-
constants.interfaces.MANY_TO_ANY,
|
|
444
|
-
|
|
445
|
-
"none",
|
|
446
|
-
].includes(field?.meta?.interface)) ||
|
|
447
|
-
(field?.meta?.interface === constants.interfaces.TRANSLATIONS &&
|
|
448
|
-
!field?.meta?.hidden &&
|
|
449
|
-
language_codes?.length &&
|
|
450
|
-
!onlyFormFields) ||
|
|
451
|
-
([
|
|
452
|
-
constants.interfaces.OBJECT,
|
|
453
|
-
constants.interfaces.SEO,
|
|
454
|
-
constants.interfaces.ITEMS,
|
|
455
|
-
].includes(field?.meta?.interface) &&
|
|
456
|
-
!field?.meta?.hidden &&
|
|
457
|
-
!onlyFormFields &&
|
|
459
|
+
onlyFormFields &&
|
|
460
|
+
isEmpty(getValue(existingForm, currentPath)) &&
|
|
458
461
|
getNodes)
|
|
459
462
|
) {
|
|
460
463
|
getSelectedNodes({
|
|
@@ -540,7 +543,7 @@ const validateMetaRules = (
|
|
|
540
543
|
node.value,
|
|
541
544
|
node.key,
|
|
542
545
|
(path) => {
|
|
543
|
-
const newPath = path.replace(/\[0\]\./,
|
|
546
|
+
const newPath = path.replace(/\[0\]\./, `.${lang}.`);
|
|
544
547
|
return newPath;
|
|
545
548
|
}
|
|
546
549
|
);
|
|
@@ -550,7 +553,7 @@ const validateMetaRules = (
|
|
|
550
553
|
});
|
|
551
554
|
|
|
552
555
|
transformedPath = rebuildFullPath(node.value, node.key, (path) =>
|
|
553
|
-
path.replace(/\[0\]\./,
|
|
556
|
+
path.replace(/\[0\]\./, `.${lang}.`)
|
|
554
557
|
);
|
|
555
558
|
}
|
|
556
559
|
|
|
@@ -1110,7 +1113,12 @@ const validateField = (
|
|
|
1110
1113
|
timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
1111
1114
|
translatedPath = null
|
|
1112
1115
|
) => {
|
|
1113
|
-
if (
|
|
1116
|
+
if (
|
|
1117
|
+
onlyFormFields == true &&
|
|
1118
|
+
value === undefined &&
|
|
1119
|
+
field?.meta?.interface !== constants.interfaces.SEO
|
|
1120
|
+
)
|
|
1121
|
+
return;
|
|
1114
1122
|
|
|
1115
1123
|
const { is_m2a_item } = field?.meta;
|
|
1116
1124
|
const currentPath = fieldPath
|