(): Formatter<string>Creates a Formatter that converts an Issue into a human-readable multi-line string.
When to use
Use when you need to format a SchemaIssue.Issue as error messages for
logging, CLI output, or developer-facing diagnostics.
Details
This is the default formatter used by SchemaIssue.toString().
- Flattens the issue tree into
{ message, path }entries using defaultLeafHook and defaultCheckHook. - Each entry is rendered as
"<message>"or"<message>\n at <path>". - Multiple entries are joined with newlines.
Example (Formatting an issue as a string)
import { SchemaIssue } from "effect"
const formatter = SchemaIssue.makeFormatterDefault()export function function makeFormatterDefault(): Formatter<string>Creates a
Formatter
that converts an
Issue
into a
human-readable multi-line string.
When to use
Use when you need to format a SchemaIssue.Issue as error messages for
logging, CLI output, or developer-facing diagnostics.
Details
This is the default formatter used by SchemaIssue.toString().
- Flattens the issue tree into
{ message, path } entries using
defaultLeafHook
and
defaultCheckHook
.
- Each entry is rendered as
"<message>" or "<message>\n at <path>".
- Multiple entries are joined with newlines.
Example (Formatting an issue as a string)
import { SchemaIssue } from "effect"
const formatter = SchemaIssue.makeFormatterDefault()
makeFormatterDefault(): 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<string> {
return (issue: Issueissue) =>
function toDefaultIssues(
issue: Issue,
path: ReadonlyArray<PropertyKey>,
leafHook: LeafHook,
checkHook: CheckHook
): Array<DefaultIssue>
toDefaultIssues(issue: Issueissue, [], 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, 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)
.Array<DefaultIssue>.map<string>(callbackfn: (value: DefaultIssue, index: number, array: DefaultIssue[]) => string, thisArg?: any): string[]Calls a defined callback function on each element of an array, and returns an array that contains the results.
map(function formatDefaultIssue(
issue: DefaultIssue
): string
formatDefaultIssue)
.Array<string>.join(separator?: string): stringAdds all the elements of an array into a string, separated by the specified separator string.
join("\n")
}