@interweave/interweave
TypeScript icon, indicating that this package has built-in type declarations

0.0.42 • Public • Published

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"
    }
}

Readme

Keywords

none

Package Sidebar

Install

npm i @interweave/interweave

Weekly Downloads

0

Version

0.0.42

License

ISC

Unpacked Size

112 kB

Total Files

26

Last publish

Collaborators

  • carbonology