Skip to content

Commit

Permalink
wipp
Browse files Browse the repository at this point in the history
  • Loading branch information
ukrbublik committed Mar 11, 2024
1 parent f61017d commit c286cc7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/core/modules/i18n/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import i18next from 'i18next';
import i18next from "i18next";
import { translations as validationTranslations } from "./validation/translations";

export const NSV = "raqbvalidation";
Expand Down
12 changes: 9 additions & 3 deletions packages/core/modules/utils/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
import {defaultValue, getFirstDefined, deepEqual} from "../utils/stuff";
import {getItemInListValues} from "../utils/listValues";
import {defaultOperatorOptions} from "../utils/defaultUtils";
import {fixPathsInTree, getItemByPath} from "../utils/treeUtils";
import {fixPathsInTree, getItemByPath, getFlatTree} from "../utils/treeUtils";
import {setFuncDefaultArg} from "../utils/funcUtils";
import {queryString} from "../export/queryString";
import * as constants from "../i18n/validation/constains";
Expand Down Expand Up @@ -68,7 +68,7 @@ export const validateAndFixTree = (newTree, _oldTree, newConfig, oldConfig, remo
newTree, _oldTree, newConfig, oldConfig, removeEmptyGroups, removeIncompleteRules, forceFix
);
if (isSanitized && allErrros.length) {
console.warn("Tree validation errors: ", allErrros)
console.warn("Tree validation errors: ", allErrros);
}
fixedTree = fixPathsInTree(fixedTree);
return fixedTree;
Expand All @@ -85,10 +85,12 @@ export const _validateTree = (
errors: {},
};
const fixedTree = validateItem(tree, [], null, meta, c);
const flatItems = getFlatTree(fixedTree).items;
const isSanitized = meta.sanitized;
const errorsArr = [];
for (const id in meta.errors) {
let {path, errors} = meta.errors[id];
const flatItem = flatItems[id];
if (translateErrors) {
errors = errors.map(e => {
return {
Expand All @@ -99,10 +101,14 @@ export const _validateTree = (
}
let errorItem = { path, errors };
if (stringifyRules) {
const item = getItemByPath(tree, path);
const item = getItemByPath(fixedTree, path);
const itemStr = queryString(item, config, false, true);
errorItem.itemStr = itemStr;
}
// todo
// if (1) {
// errorItem.itemMeta = flatItem?.nums;
// }
errorsArr.push(errorItem);
}
return [fixedTree, errorsArr, isSanitized];
Expand Down

0 comments on commit c286cc7

Please sign in to comment.