Hyperlinkv0.8.0-beta.28

Schema

Schema.annotatefunctioneffect/Schema.ts:537
<S extends Top>(
  annotations: Annotations.Bottom<S["Type"], S["~type.parameters"]>
): (self: S) => S["Rebuild"]

Adds metadata annotations to a schema without changing its runtime behavior. This is the pipeable (curried) counterpart of the .annotate method.

Details

Annotations provide extra context used by documentation generators, JSON Schema converters, error formatters, and other tooling. Common keys include title, description, examples, message, and identifier.

Example (Adding a title and description)

import { Schema } from "effect"

const Age = Schema.Number.pipe(
  Schema.annotate({
    title: "Age",
    description: "A non-negative integer representing age in years"
  })
)
annotationsannotateEncoded
Source effect/Schema.ts:5373 lines
export function annotate<S extends Top>(annotations: Annotations.Bottom<S["Type"], S["~type.parameters"]>) {
  return (self: S) => self.annotate(annotations)
}