Hyperlinkv0.8.0-beta.28

SchemaGetter

SchemaGetter.failfunctioneffect/SchemaGetter.ts:154
<T, E>(f: (oe: Option.Option<E>) => SchemaIssue.Issue): Getter<T, E>

Creates a getter that always fails with the given issue.

When to use

Use when you need a schema getter that unconditionally rejects input.

  • Building custom validation getters that produce specific error types.

Details

  • Always fails with the Issue returned by f.
  • The failure function receives the original Option<E> input for error context.

Example (Defining an always-failing getter)

import { Option, SchemaGetter, SchemaIssue } from "effect"

const rejectAll = SchemaGetter.fail<string, string>(
  (oe) => new SchemaIssue.InvalidValue(oe, { message: "not allowed" })
)
export function fail<T, E>(f: (oe: Option.Option<E>) => SchemaIssue.Issue): Getter<T, E> {
  return new Getter((oe) => Effect.fail(f(oe)))
}
Referenced by 1 symbols