nox-validation 1.6.6 → 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.
Files changed (2) hide show
  1. package/lib/validate.js +33 -25
  2. package/package.json +1 -1
package/lib/validate.js CHANGED
@@ -430,31 +430,34 @@ const validateMetaRules = (
430
430
  }
431
431
 
432
432
  if (
433
- (isEmpty(fieldValue) &&
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
- constants.interfaces.FILES,
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({
@@ -1110,7 +1113,12 @@ const validateField = (
1110
1113
  timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone,
1111
1114
  translatedPath = null
1112
1115
  ) => {
1113
- if (onlyFormFields == true && value === undefined) return;
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nox-validation",
3
- "version": "1.6.6",
3
+ "version": "1.6.7",
4
4
  "description": "validate dynamic schema",
5
5
  "main": "index.js",
6
6
  "scripts": {