<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"
})
)export function function annotate<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"
})
)
annotate<function (type parameter) S in annotate<S extends Top>(annotations: Annotations.Bottom<S["Type"], S["~type.parameters"]>): (self: S) => S["Rebuild"]S extends Top>(annotations: Annotations.Bottom<
S["Type"],
S["~type.parameters"]
>
(parameter) annotations: {
message: string | undefined;
messageUnexpectedKey: string | undefined;
identifier: string | undefined;
parseOptions: SchemaAST.ParseOptions | undefined;
meta: Meta | undefined;
brands: ReadonlyArray<string> | undefined;
toArbitrary: ToArbitrary.Declaration<T, TypeParameters> | undefined;
default: T | undefined;
examples: ReadonlyArray<T> | undefined;
expected: string | undefined;
title: string | undefined;
description: string | undefined;
documentation: string | undefined;
readOnly: boolean | undefined;
writeOnly: boolean | undefined;
format: string | undefined;
contentEncoding: string | undefined;
contentMediaType: string | undefined;
}
annotations: Annotations.interface Annotations.Bottom<T, TypeParameters extends ReadonlyArray<Constraint>>Base annotations shared by all composite schema nodes. Extends
Documentation
with error messages, branding, parse options, and
arbitrary generation hooks.
Declaration
and other annotation
interfaces build on top of this.
Bottom<function (type parameter) S in annotate<S extends Top>(annotations: Annotations.Bottom<S["Type"], S["~type.parameters"]>): (self: S) => S["Rebuild"]S["Type"], function (type parameter) S in annotate<S extends Top>(annotations: Annotations.Bottom<S["Type"], S["~type.parameters"]>): (self: S) => S["Rebuild"]S["~type.parameters"]>) {
return (self: S extends Topself: function (type parameter) S in annotate<S extends Top>(annotations: Annotations.Bottom<S["Type"], S["~type.parameters"]>): (self: S) => S["Rebuild"]S) => self: S extends Topself.Bottom<unknown, unknown, unknown, unknown, AST, Top, unknown, unknown, any, unknown, Mutability, Optionality, ConstructorDefault, Mutability, Optionality>.annotate(annotations: Annotations.Bottom<S["Type"], S["~type.parameters"]>): S["Rebuild"]annotate(annotations: Annotations.Bottom<
S["Type"],
S["~type.parameters"]
>
(parameter) annotations: {
message: string | undefined;
messageUnexpectedKey: string | undefined;
identifier: string | undefined;
parseOptions: SchemaAST.ParseOptions | undefined;
meta: Meta | undefined;
brands: ReadonlyArray<string> | undefined;
toArbitrary: ToArbitrary.Declaration<T, TypeParameters> | undefined;
default: T | undefined;
examples: ReadonlyArray<T> | undefined;
expected: string | undefined;
title: string | undefined;
description: string | undefined;
documentation: string | undefined;
readOnly: boolean | undefined;
writeOnly: boolean | undefined;
format: string | undefined;
contentEncoding: string | undefined;
contentMediaType: string | undefined;
}
annotations)
}