InvalidValueRepresents a schema issue produced when the input has the correct type but its value violates a constraint (e.g. a string that is too short, a number out of range).
When to use
Use when you need to detect constraint violations from Schema.filter,
Schema.minLength, Schema.greaterThan, or similar checks.
Details
actualisOption.some(value)when the failing value is known, orOption.none()when absent.annotationsoptionally carries amessagestring for formatting.- The default formatter renders this as
"Invalid data <actual>"unless a custommessageannotation is provided.
Example (Returning InvalidValue from a custom filter)
import { Option, SchemaIssue } from "effect"
const issue = new SchemaIssue.InvalidValue(
Option.some(""),
{ message: "must not be empty" }
)
console.log(String(issue))
// "must not be empty"export class class InvalidValueclass InvalidValue {
_tag: 'InvalidValue';
actual: Option.Option<unknown>;
annotations: Schema.Annotations.Issue | undefined;
toString: (this: Issue) => string;
}
Represents a schema issue produced when the input has the correct type but its value violates a
constraint (e.g. a string that is too short, a number out of range).
When to use
Use when you need to detect constraint violations from Schema.filter,
Schema.minLength, Schema.greaterThan, or similar checks.
Details
actual is Option.some(value) when the failing value is known, or
Option.none() when absent.
annotations optionally carries a message string for formatting.
- The default formatter renders this as
"Invalid data <actual>" unless a
custom message annotation is provided.
Example (Returning InvalidValue from a custom filter)
import { Option, SchemaIssue } from "effect"
const issue = new SchemaIssue.InvalidValue(
Option.some(""),
{ message: "must not be empty" }
)
console.log(String(issue))
// "must not be empty"
InvalidValue extends class BaseBase {
readonly InvalidValue._tag: "InvalidValue"_tag = "InvalidValue"
/**
* The value that caused the issue.
*/
readonly InvalidValue.actual: Option.Option<unknown>The value that caused the issue.
actual: import OptionOption.type Option<A> = Option.None<A> | Option.Some<A>The Option data type represents optional values. An Option<A> is either
Some<A>, containing a value of type A, or None, representing absence.
When to use
Use to represent initial values that may not yet exist
- Returning from partial functions (not defined for all inputs)
- Managing optional fields in data structures
Namespace containing utility types for Option.
When to use
Use to access type-level helpers associated with Option.
Option<unknown>
/**
* The metadata for the issue.
*/
readonly InvalidValue.annotations: Schema.Annotations.Issue | undefinedThe metadata for the issue.
annotations: import SchemaSchema.Annotations.interface Annotations.IssueAnnotations that can be attached to schema issues.
Details
The optional message field overrides the default issue message.
Issue | undefined
constructor(
/**
* The value that caused the issue.
*/
actual: Option.Option<unknown>The value that caused the issue.
actual: import OptionOption.type Option<A> = Option.None<A> | Option.Some<A>The Option data type represents optional values. An Option<A> is either
Some<A>, containing a value of type A, or None, representing absence.
When to use
Use to represent initial values that may not yet exist
- Returning from partial functions (not defined for all inputs)
- Managing optional fields in data structures
Namespace containing utility types for Option.
When to use
Use to access type-level helpers associated with Option.
Option<unknown>,
/**
* The metadata for the issue.
*/
annotations: Schema.Annotations.Issue | undefinedThe metadata for the issue.
annotations?: import SchemaSchema.Annotations.interface Annotations.IssueAnnotations that can be attached to schema issues.
Details
The optional message field overrides the default issue message.
Issue | undefined
) {
super()
this.InvalidValue.actual: Option.Option<unknown>The value that caused the issue.
actual = actual: Option.Option<unknown>The value that caused the issue.
actual
this.InvalidValue.annotations: Schema.Annotations.Issue | undefinedThe metadata for the issue.
annotations = annotations: Schema.Annotations.Issue | undefinedThe metadata for the issue.
annotations
}
}