Files
zkldi_Tachi/server/src/common/prudence.ts
T
2021-05-21 15:19:50 +01:00

13 lines
556 B
TypeScript

// @todo #118 Investigate why this import triggers a circular dependency according to madge.
import p, { PrudenceError, ValidSchemaValue } from "prudence";
export function FormatPrError(err: PrudenceError, foreword = "Error") {
return `${foreword}: ${err.keychain} | ${err.message}${
typeof err.userVal === "object" && err.userVal !== null
? ""
: ` | Received ${err.userVal} [${err.userVal === null ? "null" : typeof err.userVal}]`
}.`;
}
export const optNull = (v: ValidSchemaValue) => p.optional(p.nullable(v));