InvalidTypeRepresents 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
astis the schema node that expected a different type.actualisOption.some(value)when the input was present, orOption.none()when no value was provided.- The default formatter renders this as
"Expected <type>, got <actual>".
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"
}
}export class class InvalidTypeclass InvalidType {
_tag: 'InvalidType';
ast: SchemaAST.AST;
actual: Option.Option<unknown>;
toString: (this: Issue) => string;
}
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
ast is the schema node that expected a different type.
actual is Option.some(value) when the input was present, or
Option.none() when no value was provided.
- The default formatter renders this as
"Expected <type>, got <actual>".
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"
}
}
InvalidType extends class BaseBase {
readonly InvalidType._tag: "InvalidType"_tag = "InvalidType"
/**
* The schema that caused the issue.
*/
readonly InvalidType.ast: SchemaAST.ASTThe schema that caused the issue.
ast: import SchemaASTSchemaAST.type SchemaAST.AST = /*unresolved*/ anyAST
/**
* The input value that caused the issue.
*/
readonly InvalidType.actual: Option.Option<unknown>The input value that caused the issue.
actual: import OptionOption.type Option.Option = /*unresolved*/ anyOption<unknown>
constructor(
/**
* The schema that caused the issue.
*/
ast: SchemaAST.ASTThe schema that caused the issue.
ast: import SchemaASTSchemaAST.type SchemaAST.AST = /*unresolved*/ anyAST,
/**
* The input value that caused the issue.
*/
actual: Option.Option<unknown>The input value that caused the issue.
actual: import OptionOption.type Option.Option = /*unresolved*/ anyOption<unknown>
) {
super()
this.InvalidType.ast: SchemaAST.ASTThe schema that caused the issue.
ast = ast: SchemaAST.ASTThe schema that caused the issue.
ast
this.InvalidType.actual: Option.Option<unknown>The input value that caused the issue.
actual = actual: Option.Option<unknown>The input value that caused the issue.
actual
}
}