(options?: {
readonly leafHook?: LeafHook | undefined
readonly checkHook?: CheckHook | undefined
}): Formatter<StandardSchemaV1.FailureResult>Creates a Formatter that produces a StandardSchemaV1.FailureResult.
When to use
Use when you need schema parse errors in Standard Schema V1 format, optionally customizing leaf or check issue rendering.
Details
- Returns a
Formatter<StandardSchemaV1.FailureResult>. - Each leaf issue is flattened into
{ message, path }entries. Pointerpaths are accumulated to produce full property paths.- Falls back to defaultLeafHook / defaultCheckHook when no hooks are provided.
Example (Creating a Standard Schema V1 formatter)
import { SchemaIssue } from "effect"
const formatter = SchemaIssue.makeFormatterStandardSchemaV1()export function function makeFormatterStandardSchemaV1(options?: {
readonly leafHook?: LeafHook | undefined
readonly checkHook?: CheckHook | undefined
}): Formatter<StandardSchemaV1.FailureResult>
Creates a
Formatter
that produces a StandardSchemaV1.FailureResult.
When to use
Use when you need schema parse errors in
Standard Schema V1
format, optionally customizing leaf or check issue rendering.
Details
- Returns a
Formatter<StandardSchemaV1.FailureResult>.
- Each leaf issue is flattened into
{ message, path } entries.
Pointer paths are accumulated to produce full property paths.
- Falls back to
defaultLeafHook
/
defaultCheckHook
when no
hooks are provided.
Example (Creating a Standard Schema V1 formatter)
import { SchemaIssue } from "effect"
const formatter = SchemaIssue.makeFormatterStandardSchemaV1()
makeFormatterStandardSchemaV1(options: {
readonly leafHook?: LeafHook | undefined
readonly checkHook?: CheckHook | undefined
}
options?: {
readonly leafHook?: LeafHook | undefinedleafHook?: type LeafHook = (issue: Leaf) => stringCallback type used to format
Leaf
issues into strings.
When to use
Use when customizing how
makeFormatterStandardSchemaV1
renders
terminal issues.
LeafHook | undefined
readonly checkHook?: CheckHook | undefinedcheckHook?: type CheckHook = (
issue: Filter
) => string | undefined
Callback type used to format
Filter
issues into strings.
When to use
Use when customizing how
makeFormatterStandardSchemaV1
renders
filter failures.
Details
- Returns
string to override the message, or undefined to fall back to
the default formatting.
CheckHook | undefined
}): interface Formatter<out Format>A function type that converts an
Issue
into a formatted
representation. Specialisation of the generic Formatter from
Formatter.ts with Value fixed to Issue.
Formatter<import StandardSchemaV1StandardSchemaV1.type StandardSchemaV1.FailureResult = /*unresolved*/ anyFailureResult> {
return (issue: Issueissue) => ({
issues: DefaultIssue[]issues: function toDefaultIssues(
issue: Issue,
path: ReadonlyArray<PropertyKey>,
leafHook: LeafHook,
checkHook: CheckHook
): Array<DefaultIssue>
toDefaultIssues(issue: Issueissue, [], options: {
readonly leafHook?: LeafHook | undefined
readonly checkHook?: CheckHook | undefined
}
options?.leafHook?: LeafHook | undefinedleafHook ?? const defaultLeafHook: LeafHookReturns the built-in
LeafHook
used by default formatters.
When to use
Use as the default leaf renderer when customizing only the
CheckHook
.
Details
- Checks for a
message annotation first; returns it if present.
- Otherwise generates a default message per
_tag:
InvalidType → "Expected <type>, got <actual>"
InvalidValue → "Invalid data <actual>"
MissingKey → "Missing key"
UnexpectedKey → "Unexpected key with value <actual>"
Forbidden → "Forbidden operation"
OneOf → "Expected exactly one member to match the input <actual>"
Example (Formatting Standard Schema issues with defaultLeafHook)
import { SchemaIssue } from "effect"
const formatter = SchemaIssue.makeFormatterStandardSchemaV1({
leafHook: SchemaIssue.defaultLeafHook
})
defaultLeafHook, options: {
readonly leafHook?: LeafHook | undefined
readonly checkHook?: CheckHook | undefined
}
options?.checkHook?: CheckHook | undefinedcheckHook ?? const defaultCheckHook: CheckHookReturns the built-in
CheckHook
used by default formatters.
When to use
Use as the default filter renderer when customizing only the
LeafHook
.
Details
- Looks for a
message annotation on the inner issue first, then on the
filter itself.
- Returns
undefined when no annotation is found, causing the formatter to
fall back to "Expected <filter>, got <actual>".
defaultCheckHook)
})
}