Files
zkldi_Tachi/server/src/utils/prudence.ts
T
2022-03-14 19:21:59 +00:00

15 lines
540 B
TypeScript

import p, { PrudenceError, ValidSchemaValue } from "prudence";
export function FormatPrError(err: PrudenceError, foreword = "Error") {
const receivedText =
typeof err.userVal === "object" && err.userVal !== null
? ""
: ` | Received ${err.userVal} [${err.userVal === null ? "null" : typeof err.userVal}]`;
return `${foreword}: ${err.keychain} | ${err.message}${receivedText}.`;
}
export const optNull = (v: ValidSchemaValue) => p.optional(p.nullable(v));
export const optNullFluffStrField = optNull(p.isBoundedString(3, 140));