Hyperlinkv0.8.0-beta.28

SchemaIssue

SchemaIssue.Filterclasseffect/SchemaIssue.ts:159
Filter

Represents a schema issue produced when a schema filter (refinement check) fails.

When to use

Use when you need to inspect a schema issue that records which refinement check rejected the value.

Details

  • actual is the raw input value that was tested (plain unknown, not wrapped in Option).
  • filter is the AST filter node that produced this issue.
  • issue is the inner issue describing the failure reason.

Example (Matching a Filter issue)

import { SchemaIssue } from "effect"

function describe(issue: SchemaIssue.Issue): string {
  if (issue._tag === "Filter") {
    return `Filter failed on: ${JSON.stringify(issue.actual)}`
  }
  return String(issue)
}
export class Filter extends Base {
  readonly _tag = "Filter"
  /**
   * The input value that caused the issue.
   */
  readonly actual: unknown
  /**
   * The filter that failed.
   */
  readonly filter: SchemaAST.Filter<unknown>
  /**
   * The issue that occurred.
   */
  readonly issue: Issue

  constructor(
    /**
     * The input value that caused the issue.
     */
    actual: unknown,
    /**
     * The filter that failed.
     */
    filter: SchemaAST.Filter<any>,
    /**
     * The issue that occurred.
     */
    issue: Issue
  ) {
    super()
    this.actual = actual
    this.filter = filter
    this.issue = issue
  }
}
Referenced by 2 symbols