Package: effect
Module: Schema
Adds key-level annotations to a schema field. This is the pipeable
(curried) counterpart of the .annotateKey method.
Details
Key annotations apply to a field’s position inside a Struct or Tuple
rather than to the field’s value type. They can carry a
messageMissingKey to customise the error shown when the field is absent,
as well as standard documentation fields such as title, description,
and examples.
Example (Customizing the missing-key message for a required field)
import { Schema } from "effect"
const schema = Schema.Struct({
username: Schema.String.pipe(
Schema.annotateKey({
description: "The username used to log in",
messageMissingKey: "Username is required"
})
)
})
Signature
declare const annotateKey: <S extends Top>(annotations: Annotations.Key<S["Type"]>) => (self: S) => S["Rebuild"]
Since v4.0.0