Overview

Record Schema

s.record(schema)

Record type with element schema

A record is a collection of key-value pairs. It can be used as a list of objects that have a unique key.

Methods:
.validate: method

Custom validation function

.preview: method

Decide what Val Studio shows for a value wherever a preview of it is needed — a row in a list, a reference, a search hit: a title, and optionally a subtitle and an image. It is declared on the schema of the value being previewed, so a record gets its rows from its item schema.

s.record(
  s.object({
    name: s.string(),
    age: s.number(),
  }).preview(({ val }) => ({ title: val.name, subtitle: String(val.age) })),
)
.router: method

Use the router method to automatically generate pages for each entry in the record

Example:
s.record(s.object({
  name: s.string(),
  age: s.number(),
}))