UNPKG

@inkline/inkline

Version:

Inkline is the intuitive UI Components library that gives you a developer-friendly foundation for building high-quality, accessible, and customizable Vue.js 3 Design Systems.

23 lines (22 loc) 665 B
import { reservedValidationFields } from "@inkline/inkline/constants"; export function setSchemaStateRecursively(schema, values) { const resolvedSchema = { ...schema }; Object.keys(values).forEach((key) => { const value = values[key]; if (!Array.isArray(schema)) { resolvedSchema[key] = value; } }); Object.keys(schema).filter((key) => !reservedValidationFields.includes(key)).forEach((key) => { const field = schema[key]; if (typeof schema[key] === "object" || Array.isArray(schema[key])) { resolvedSchema[key] = setSchemaStateRecursively( field, values ); } }); return resolvedSchema; }