Package: effect
Module: SchemaGetter
Creates a getter that validates a value using an effectful check function.
When to use
Use when you need a schema getter to validate a decoded value (e.g. check a constraint or call an external service).
Details
Some — None passes through.undefined or true — value is valid, passes through.false or a string — value is invalid, fails with an Issue.Issue object — fails with that issue directly.{ path, issue } — fails with a nested path issue (issue may be a
message string or a full SchemaIssue.Issue).Example (Validating effectfully)
import { Effect, SchemaGetter } from "effect"
const nonNegative = SchemaGetter.checkEffect<number>((n) =>
Effect.succeed(n >= 0 ? undefined : "must be non-negative")
)
See
transform when you need to change the value, not just validatefail for unconditional failureSignature
declare const checkEffect: <T, R = never>(f: (input: T, options: SchemaAST.ParseOptions) => Effect.Effect<undefined | boolean | Schema.FilterIssue, never, R>) => Getter<T, T, R>
Since v4.0.0