nox-validation 1.3.4 → 1.3.6
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/helpers.js +24 -4
- package/lib/validate.js +11 -6
- package/package.json +1 -1
package/lib/helpers.js
CHANGED
|
@@ -374,6 +374,16 @@ const generateRelationalField = (
|
|
|
374
374
|
constants.types.NUMBER,
|
|
375
375
|
constants.types.NUMBER
|
|
376
376
|
),
|
|
377
|
+
generateField(
|
|
378
|
+
"collection_id",
|
|
379
|
+
`${key}.existing.collection_id`,
|
|
380
|
+
constants.types.OBJECT_ID,
|
|
381
|
+
constants.types.OBJECT_ID,
|
|
382
|
+
[],
|
|
383
|
+
"none",
|
|
384
|
+
[],
|
|
385
|
+
collection_id_meta
|
|
386
|
+
),
|
|
377
387
|
generateField(
|
|
378
388
|
"item",
|
|
379
389
|
`${key}.existing.item`,
|
|
@@ -400,6 +410,16 @@ const generateRelationalField = (
|
|
|
400
410
|
constants.types.NUMBER,
|
|
401
411
|
constants.types.NUMBER
|
|
402
412
|
),
|
|
413
|
+
generateField(
|
|
414
|
+
"collection_id",
|
|
415
|
+
`${key}.delete.collection_id`,
|
|
416
|
+
constants.types.OBJECT_ID,
|
|
417
|
+
constants.types.OBJECT_ID,
|
|
418
|
+
[],
|
|
419
|
+
"none",
|
|
420
|
+
[],
|
|
421
|
+
collection_id_meta
|
|
422
|
+
),
|
|
403
423
|
generateField(
|
|
404
424
|
"item",
|
|
405
425
|
`${key}.delete.item`,
|
|
@@ -422,7 +442,7 @@ const generateRelationalField = (
|
|
|
422
442
|
constants.types.STRING
|
|
423
443
|
),
|
|
424
444
|
generateField(
|
|
425
|
-
"
|
|
445
|
+
"collection_id",
|
|
426
446
|
`${key}.create.collection_id`,
|
|
427
447
|
constants.types.OBJECT_ID,
|
|
428
448
|
constants.types.OBJECT_ID,
|
|
@@ -442,7 +462,7 @@ const generateRelationalField = (
|
|
|
442
462
|
`${key}.create.item`,
|
|
443
463
|
constants.types.OBJECT,
|
|
444
464
|
constants.types.OBJECT,
|
|
445
|
-
collectionFields,
|
|
465
|
+
[...collectionFields],
|
|
446
466
|
"none",
|
|
447
467
|
[constants.types.OBJECT_ID],
|
|
448
468
|
{ ...collection_id_meta, is_m2a_item: true }
|
|
@@ -463,7 +483,7 @@ const generateRelationalField = (
|
|
|
463
483
|
constants.types.STRING
|
|
464
484
|
),
|
|
465
485
|
generateField(
|
|
466
|
-
"
|
|
486
|
+
"collection_id",
|
|
467
487
|
`${key}.update.collection_id`,
|
|
468
488
|
constants.types.OBJECT_ID,
|
|
469
489
|
constants.types.OBJECT_ID,
|
|
@@ -483,7 +503,7 @@ const generateRelationalField = (
|
|
|
483
503
|
`${key}.update.item`,
|
|
484
504
|
constants.types.OBJECT,
|
|
485
505
|
constants.types.OBJECT,
|
|
486
|
-
collectionFields,
|
|
506
|
+
[...collectionFields],
|
|
487
507
|
"none",
|
|
488
508
|
[constants.types.OBJECT_ID]
|
|
489
509
|
),
|
package/lib/validate.js
CHANGED
|
@@ -284,6 +284,7 @@ const validateMetaRules = (
|
|
|
284
284
|
constants.interfaces.ONE_TO_MANY,
|
|
285
285
|
constants.interfaces.MANY_TO_ONE,
|
|
286
286
|
constants.interfaces.MANY_TO_ANY,
|
|
287
|
+
"none"
|
|
287
288
|
].includes(field?.meta?.interface)
|
|
288
289
|
) {
|
|
289
290
|
const isTranslationChild =
|
|
@@ -299,6 +300,10 @@ const validateMetaRules = (
|
|
|
299
300
|
let fPath = node.key;
|
|
300
301
|
|
|
301
302
|
if (fPath.includes("update.")) return;
|
|
303
|
+
if (fPath.includes("create.") && !isTranslationChild) return;
|
|
304
|
+
if (fPath.includes("delete.") && !isTranslationChild) return;
|
|
305
|
+
if (fPath.includes("existing.") && !isTranslationChild) return;
|
|
306
|
+
|
|
302
307
|
|
|
303
308
|
const label = formatLabel(node.display_label);
|
|
304
309
|
const message = error_messages.REQUIRED.replace("{field}", label);
|
|
@@ -811,18 +816,18 @@ const validateField = (
|
|
|
811
816
|
typeChecks[constants.types.OBJECT](value)
|
|
812
817
|
) {
|
|
813
818
|
let itemSchemaId = null;
|
|
814
|
-
|
|
819
|
+
let childrenToValidate = field.children
|
|
815
820
|
if (is_m2a_item) {
|
|
816
821
|
const fieldPath = getM2AItemParentPath(currentPath);
|
|
817
822
|
if (fieldPath) {
|
|
818
823
|
itemSchemaId = getValue(formData, fieldPath)?.collection_id;
|
|
824
|
+
if(!itemSchemaId){
|
|
825
|
+
childrenToValidate = []
|
|
826
|
+
}else{
|
|
827
|
+
childrenToValidate = field.children.filter((child) => child.schema_id === itemSchemaId)
|
|
828
|
+
}
|
|
819
829
|
}
|
|
820
830
|
}
|
|
821
|
-
|
|
822
|
-
const childrenToValidate = itemSchemaId
|
|
823
|
-
? field.children.filter((child) => child.schema_id === itemSchemaId)
|
|
824
|
-
: field.children;
|
|
825
|
-
|
|
826
831
|
childrenToValidate.forEach((child) =>
|
|
827
832
|
validateField(
|
|
828
833
|
child,
|