Skip to content

interweave-hq/interweave

Repository files navigation

Interweave

Interweave is a platform for creating user interfaces from static JSON. The Interweave configuration objects are meant to be checked into version control and tied closely to database and API changes.

validate

The `validate()' function is a good way to test an object against your configuration. This is useful for validating user input from forms and requests.

import { validate } from "@interweave/interweave";

// Validate and throw any errors to a console immediately
// Good for using in a build pipeline
validate(object, schema);

// Run and collect errors to an object
// Good for forms and handling form errors
const errorsObject = validate(object, schema, { returnErrors: true });

Architecture

Flattening and expanding

We will take nested objects, flatten them down into their keys

{
    title: "Some Title",
    description: "some description",
    author: {
        name: "mike"
    }
}

Error and form object becomes:

{
    title: "Some Title",
    description: "some description",
    "author.name": "mike"
}

Then we use those keys to expand back into a wider object before submission:

{
    title: "Some Title",
    description: "some description",
    author: {
        name: "mike"
    }
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published