nox-validation 1.7.9 → 1.8.1

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/index.js CHANGED
@@ -8,9 +8,6 @@ const {
8
8
  getDefaultValues,
9
9
  } = require("./lib/helpers");
10
10
 
11
- const optimizedValidate = require("./lib/validate.optimized");
12
- const helpersOptimized = require("./lib/helpers.optimized");
13
-
14
11
  module.exports = {
15
12
  validate,
16
13
  CONSTANTS: constants,
@@ -23,16 +20,4 @@ module.exports = {
23
20
  setValueByDynamicKey: setValue,
24
21
  getTreeDefaultValues: getDefaultValues,
25
22
  },
26
- optimized: {
27
- validate: optimizedValidate.validate,
28
- helpers: {
29
- validateSingleField: helpersOptimized.validateField,
30
- validateType: helpersOptimized.typeChecks,
31
- fieldsMapping: helpersOptimized.getFieldsGroupBySchemaId,
32
- convertTree: helpersOptimized.buildNestedStructure,
33
- getValueByDynamicKey: helpersOptimized.getValue,
34
- setValueByDynamicKey: helpersOptimized.setValue,
35
- getTreeDefaultValues: helpersOptimized.getDefaultValues,
36
- },
37
- },
38
23
  };
package/lib/helpers.js CHANGED
@@ -315,7 +315,7 @@ const generateField = (
315
315
  alternateType = [],
316
316
  meta = {
317
317
  required: false,
318
- nullable: false,
318
+ nullable: true,
319
319
  hidden: false,
320
320
  },
321
321
  ) => {
@@ -355,7 +355,7 @@ const generateField = (
355
355
  };
356
356
  };
357
357
 
358
- const createChildrenFieldsFiles = (key) => {
358
+ const createChildrenFieldsFiles = (key, item) => {
359
359
  const existingField = generateField(
360
360
  "existing",
361
361
  `${key}.existing`,
package/lib/validate.js CHANGED
@@ -30,6 +30,14 @@ const relational_interfaces = [
30
30
  constants.interfaces.TRANSLATIONS,
31
31
  ];
32
32
 
33
+ const arrayInterfaces = [
34
+ constants.interfaces.CHECKBOX,
35
+ constants.interfaces.ITEMS,
36
+ constants.interfaces.MULTIPLE_DROPDOWN,
37
+ constants.interfaces.TAGS,
38
+ constants.interfaces.ARRAY_OF_VALUES,
39
+ ];
40
+
33
41
  const typeChecks = {
34
42
  date: (val, data) => {
35
43
  if (val instanceof Date && !isNaN(val)) return true;
@@ -330,14 +338,6 @@ const validateMetaRules = (
330
338
  );
331
339
  }
332
340
 
333
- const arrayInterfaces = [
334
- constants.interfaces.CHECKBOX,
335
- constants.interfaces.ITEMS,
336
- constants.interfaces.MULTIPLE_DROPDOWN,
337
- constants.interfaces.TAGS,
338
- constants.interfaces.ARRAY_OF_VALUES,
339
- ];
340
-
341
341
  if (
342
342
  required &&
343
343
  arrayInterfaces.includes(field?.meta?.interface) &&
@@ -1402,6 +1402,10 @@ const applyValidations = (
1402
1402
  error_messages,
1403
1403
  timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone,
1404
1404
  ) => {
1405
+ if (arrayInterfaces.includes(field.meta?.interface)) {
1406
+ currentPath = currentPath.replace(/\[\d+\]$/, "");
1407
+ }
1408
+
1405
1409
  if (
1406
1410
  !field.validations ||
1407
1411
  isEmpty(value)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nox-validation",
3
- "version": "1.7.9",
3
+ "version": "1.8.1",
4
4
  "description": "validate dynamic schema",
5
5
  "main": "index.js",
6
6
  "scripts": {