mirror of
https://github.com/zkldi/Tachi.git
synced 2026-10-06 13:58:05 +03:00
this was causing issues with vite and is potentially a bug in prudence or in vite. it's very hard to tell and i've already spent 3 hours trying to fix this, so here.
18 lines
600 B
TypeScript
18 lines
600 B
TypeScript
import { p } from "prudence";
|
|
import type { PrudenceError, ValidSchemaValue } from "prudence";
|
|
|
|
export function FormatPrError(err: PrudenceError, foreword = "Error") {
|
|
const receivedText =
|
|
typeof err.userVal === "object" && err.userVal !== null
|
|
? ""
|
|
: ` | Received ${err.userVal} [type: ${
|
|
err.userVal === null ? "null" : typeof err.userVal
|
|
}]`;
|
|
|
|
return `${foreword}: ${err.keychain ?? "null"} | ${err.message}${receivedText}.`;
|
|
}
|
|
|
|
export const optNull = (v: ValidSchemaValue) => p.optional(p.nullable(v));
|
|
|
|
export const optNullFluffStrField = optNull(p.isBoundedString(3, 140));
|