Overview

Conditions

A headless condition expression engine for filters and rule builders.

Documentation

Define fields once, then validate, evaluate, and serialize the same AND/OR expression tree on the server and in the UI. The core package has no React or DOM code — it owns the condition model, not the controls.

Headless React bindings add drafts and filter-chip orchestration. Adapters turn the same query into a TanStack Table global filter, a Drizzle where clause, or a Zero (ZQL) expression.

const contacts = defineConditions({
  fields: {
    status: {
      type: 'enum',
      schema: z.enum(['lead', 'customer', 'churned']),
      operators: ['equals', 'not', 'in'],
    },
    arr: {
      type: 'number',
      schema: z.coerce.number().min(0),
      operators: ['gte', 'lte', 'between'],
    },
  },
})

const query = contacts.parse(saved.query)
contacts.evaluate(query, { status: 'customer', arr: 84_000 })
db.select().from(table).where(
  conditionsToDrizzle(contacts, query, { columns }),
)

Useful guides

  • Basic usage
  • React
  • Chakra UI
  • shadcn
  • TanStack Table
  • Drizzle
  • Zero Sync

Version

0.1.0

Category

Logic

Downloads

52 weekly

Last updated

23 days ago

View sourceView on NPM