Hyperlinkv0.8.0-beta.28

SchemaIssue

SchemaIssue.Forbiddenclasseffect/SchemaIssue.ts:602
Forbidden

Represents a schema issue produced when a forbidden operation is encountered during parsing, such as an asynchronous Effect running inside Schema.decodeUnknownSync.

When to use

Use when you need to detect that a schema requires async execution but was run synchronously.

Details

  • actual is Option.some(value) when the input is known, or Option.none() when absent.
  • annotations optionally carries a message string.
  • The default formatter renders this as "Forbidden operation".

Example (Creating a Forbidden issue)

import { Option, SchemaIssue } from "effect"

const issue = new SchemaIssue.Forbidden(
  Option.none(),
  { message: "async operation not allowed in sync context" }
)
console.log(String(issue))
// "async operation not allowed in sync context"
export class Forbidden extends Base {
  readonly _tag = "Forbidden"
  /**
   * The input value that caused the issue.
   */
  readonly actual: Option.Option<unknown>
  /**
   * The metadata for the issue.
   */
  readonly annotations: Schema.Annotations.Issue | undefined

  constructor(
    /**
     * The input value that caused the issue.
     */
    actual: Option.Option<unknown>,
    /**
     * The metadata for the issue.
     */
    annotations: Schema.Annotations.Issue | undefined
  ) {
    super()
    this.actual = actual
    this.annotations = annotations
  }
}
Referenced by 2 symbols