Hyperlinkv0.8.0-beta.28

Schema

Schema.annotateEncodedfunctioneffect/Schema.ts:571
<S extends Top>(
  annotations: Annotations.Bottom<S["Encoded"], readonly []>
): (self: S) => S["Rebuild"]

Adds metadata annotations to the encoded side of a schema without changing its runtime behavior. This is the encoded-side counterpart of annotate, which targets the decoded (Type) side.

Details

Internally the schema is flipped so that Encoded becomes Type, annotated, and then flipped back.

Example (Adding a title to the encoded representation)

import { Schema } from "effect"

const schema = Schema.NumberFromString.pipe(
  Schema.annotateEncoded({
    title: "my title"
  })
)

console.log(Schema.toEncoded(schema).ast.annotations?.title)
// "my title"
annotationsannotate
Source effect/Schema.ts:5713 lines
export function annotateEncoded<S extends Top>(annotations: Annotations.Bottom<S["Encoded"], readonly []>) {
  return (self: S): S["Rebuild"] => flip(flip(self).annotate(annotations))
}