Represents a failed operation with one or more structured issues.
The type that would have been returned if successful
Creates a new Err instance from structured decoding issues.
The list of issues describing what went wrong and where.
Readonly
Type guard to check if this Result is an Ok. Always returns false for Err instances.
false for Err instances
const result: Result<number> = err([{ message: "Invalid input", path: [] }]);if (!result.isOk()) { // TypeScript knows result.issues exists here console.log(result.issues);} Copy
const result: Result<number> = err([{ message: "Invalid input", path: [] }]);if (!result.isOk()) { // TypeScript knows result.issues exists here console.log(result.issues);}
Returns a new Err with the same issues but a different type parameter. Since this represents an error, the transform function is never called.
The new type parameter
The function that would have transformed the value (ignored)
A new Err with the same issues
const result: Result<number> = err("Invalid input");const mapped: Result<string> = result.map(x => x.toString());// mapped = Err([{ message: "Invalid input", path: [] }]) Copy
const result: Result<number> = err("Invalid input");const mapped: Result<string> = result.map(x => x.toString());// mapped = Err([{ message: "Invalid input", path: [] }])
Represents a failed operation with one or more structured issues.