Skip to content

FEAT: maxLength/minLength options on useCollection #206

Open
@HugoPerard

Description

@HugoPerard

Is your feature request related to a problem? Please describe.
This feature can avoid to manually do some check if we want to build a collection with some length condition, for example with at least one element, or/and with 10 elements max

const collection = useCollection("collection");
...
{collection.length > 1 && <button>Remove item</button>
...
{collection.length < 10 && <button>Add item<button>}

Describe the solution you'd like
I'm thinking about two new states on the collection, with no name defined, that should transform previous to this :

const collection = useCollection("collection", { maxLength: 10, minLength: 1 });
...
{collection.canRemove && <button>Remove item</button>}
...
{collection.canAdd && <button>Add item</button>}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions