effect-io-ai

Package: effect
Module: SchemaIssue

SchemaIssue.InvalidType

Represents a schema issue produced when the runtime type of the input does not match the type expected by the schema (e.g. got null when string was expected).

When to use

Use when you need to detect basic type mismatches, such as a wrong primitive or null where an object was expected.

Details

Example (Formatting output)

import { Schema } from "effect"

try {
  Schema.decodeUnknownSync(Schema.String)(42)
} catch (e) {
  if (Schema.isSchemaError(e)) {
    console.log(String(e.issue))
    // "Expected string, got 42"
  }
}

See

Signature

declare class InvalidType { constructor(
    /**
     * The schema that caused the issue.
     */
    ast: SchemaAST.AST,
    /**
     * The input value that caused the issue.
     */
    actual: Option.Option<unknown>
  ) }

Source

Since v4.0.0