nox-validation 1.6.6 → 1.6.8

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 +32 -25
  2. package/package.json +1 -1
package/lib/validate.js CHANGED
@@ -430,31 +430,33 @@ 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 ? isEmpty(getValue(existingForm, currentPath)) : true) &&
458
460
  getNodes)
459
461
  ) {
460
462
  getSelectedNodes({
@@ -1110,7 +1112,12 @@ const validateField = (
1110
1112
  timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone,
1111
1113
  translatedPath = null
1112
1114
  ) => {
1113
- if (onlyFormFields == true && value === undefined) return;
1115
+ if (
1116
+ onlyFormFields == true &&
1117
+ value === undefined &&
1118
+ field?.meta?.interface !== constants.interfaces.SEO
1119
+ )
1120
+ return;
1114
1121
 
1115
1122
  const { is_m2a_item } = field?.meta;
1116
1123
  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.8",
4
4
  "description": "validate dynamic schema",
5
5
  "main": "index.js",
6
6
  "scripts": {