Hyperlinkv0.8.0-beta.28

SchemaGetter

SchemaGetter.forbiddenfunctioneffect/SchemaGetter.ts:187
<T, E>(message: (oe: Option.Option<E>) => string): Getter<T, E>

Creates a getter that always fails with a Forbidden issue.

When to use

Use when you need a schema getter to disallow a field or direction (encode/decode) entirely.

  • You want a clear "forbidden" error message in schema validation output.

Details

  • Always fails with SchemaIssue.Forbidden.
  • The message function receives the Option<E> input for context.

Example (Forbidding a decode direction)

import { SchemaGetter } from "effect"

const noEncode = SchemaGetter.forbidden<string, number>(
  () => "encoding is not supported"
)
constructorsfail
export function forbidden<T, E>(message: (oe: Option.Option<E>) => string): Getter<T, E> {
  return fail<T, E>((oe) => new SchemaIssue.Forbidden(oe, { message: message(oe) }))
}
Referenced by 2 symbols