diff --git a/index.ts b/index.ts index 1b6c708..290680c 100644 --- a/index.ts +++ b/index.ts @@ -1,7 +1,6 @@ export * from "./src/Options"; export * from "./src/ruleManager"; export * from "./src/helpers/validate"; -export * from "./src/helpers/newValidate"; export * from "./src/Locale"; export * from "./src/rules"; export * from "./src/converters"; diff --git a/src/helpers/newValidate.ts b/src/helpers/newValidate.ts deleted file mode 100644 index 505847f..0000000 --- a/src/helpers/newValidate.ts +++ /dev/null @@ -1,63 +0,0 @@ -import { ITraverseItem } from "../Interface"; - -export const toTraverseArray = async ( - data: any, - definition: Record -) => { - function resolvePath(data: any, path: string) { - const parts = path.split("."); - const result: Array<{ path: string; value: any }> = []; - - function traverse( - current: any, - index = 0, - resolvedPath: Array = [] - ) { - if (index >= parts.length) { - result.push({ path: resolvedPath.join("."), value: current }); - return; - } - - const part = parts[index]; - - if (part === "*") { - if (Array.isArray(current)) { - current.forEach((item, i) => { - traverse(item, index + 1, [...resolvedPath, i]); - }); - } else if (current && typeof current === "object") { - Object.keys(current).forEach((key) => { - traverse(current[key], index + 1, [...resolvedPath, key]); - }); - } else { - result.push({ - path: [...resolvedPath, "*"].join("."), - value: current, - }); - } - } else { - if (current && typeof current === "object" && part in current) { - traverse(current[part], index + 1, [...resolvedPath, part]); - } else { - result.push({ - path: [...resolvedPath, part].join("."), - value: undefined, - }); - } - } - } - - traverse(data); - return result; - } - - const checks: ITraverseItem[] = []; - - // Example usage - Object.entries(definition).forEach(([path, rules]) => { - const resolved = resolvePath(data, path); - checks.push({ path, rules, resolved }); - }); - - return checks; -};