Grounds
    Preparing search index...

    Function field

    • Tags a schema with a field ID for struct serialization.

      Field IDs must be unique within a struct and in range 0-127 (bit 7 clear). Encoder sorts fields by ascending ID; decoder validates this order.

      Type Parameters

      • T extends TSchema

      Parameters

      • fieldId: number

        Field identifier (0-127)

      • schema: T

        TypeBox or Relish schema for this field

      Returns TStructField<T>

      Tagged field schema

      import { field, RString, RU8 } from '@grounds/schema';

      const nameField = field(0, RString());
      const ageField = field(1, RU8());

      RStruct for combining fields into a struct schema