Skip to content

request: schema support #48

@productdevbook

Description

@productdevbook

By default, giving a schema,
If the incoming new data is the same key, append the new data to the values of the schema keys.
delete keys that are not compatible with the schema.

Example

const schema = {
    isPro: false,
    darkMode: false,
    pages: {
        home: false,
        settings: false,
    },
}

const result = defu(schema, { isPro: 'bbb', d: 'c', pages: { home: true } }, {schema: true})

console.log(result) // {isPro: 'bbb', darkMode: false, pages: { home: true, settings: false } }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions