Quickback Docs

Validation

Field validation rules for Quickback definitions. Enforce data integrity with built-in validators.

Coming Soon

Field-level validation in defineTable() is a planned feature and is not yet available in the current compiler. Today, validation is available via Zod schemas in action definitions using the input field.

Current Validation: Action Input Schemas

You can validate input data in custom actions using Zod schemas:

// features/invoices/actions.ts
import { defineActions } from '@quickback/compiler';
import { z } from 'zod';

export default defineActions(invoices, {
  approve: {
    description: "Approve invoice for payment",
    input: z.object({
      notes: z.string().min(1).max(500).optional(),
      amount: z.number().positive(),
    }),
    access: { roles: ["admin", "finance"] },
    execute: async ({ db, record, ctx, input }) => {
      // input is validated against the Zod schema before execution
      return record;
    },
  },
});

Planned: defineTable Validation

In a future release, defineTable() will support field-level validation rules enforced at the API level when creating or updating records.

Planned Validators

ValidatorDescriptionExample
minLengthMinimum string lengthminLength: 3
maxLengthMaximum string lengthmaxLength: 255
minMinimum number valuemin: 0
maxMaximum number valuemax: 100
patternRegex pattern matchpattern: '^[a-z]+$'
enumAllowed values listenum: ['draft', 'published']

Planned Usage

// NOT YET AVAILABLE — planned syntax
export default defineTable(posts, {
  firewall: { organization: {} },
  guards: {
    createable: ["title", "content", "status"],
    updatable: ["title", "content", "status"],
  },
  validation: {
    title: { minLength: 1, maxLength: 255 },
    status: { enum: ["draft", "published", "archived"] },
  },
  crud: {
    list: { access: { roles: ["member"] } },
    create: { access: { roles: ["member"] } },
    update: { access: { roles: ["member"] } },
  },
});

On this page