@xtandard/kit/util
@xtandard/kit/util — small shared utilities: durations, id generators (the
products’ three persisted formats), the validation core, canonical JSON and
the JSON / Actor types.
import { … } from "@xtandard/kit/util";Functions
Section titled “Functions”| Name | Summary |
|---|---|
assertValid |
Throw a ValidationError when result is invalid. |
issuesFrom |
Map valibot issues to ValidationIssues under basePath. A root issue gets basePath itself (no trailing .); a strict object’s extra key (valibot reports it as “expected never”) reads "unknown field". |
parseInput |
Validate input against schema; return the typed output or throw a ValidationError listing every issue. |
resultOf |
A { valid, errors } result from a list of issues. |
validateKeySegment |
Check a caller-supplied value that becomes one storage key segment (a tenant, an idempotency key…). It must be a non-empty string of KEY_SEGMENT_REGEX characters and must not be only dots, so it can’t escape its namespace (..) or collide with the separator. maxLength caps it (webhooks: 256). |
validateUrl |
Check an absolute URL against a policy; returns the issues (empty when the URL is acceptable). Dangerous schemes are always rejected. |
Classes
Section titled “Classes”| Name | Summary |
|---|---|
ValidationError |
Raised when an input fails validation. It carries the issues as both errors (webhooks/audit/links) and issues (entitlements); they are the same array. |
Interfaces
Section titled “Interfaces”| Name | Summary |
|---|---|
ParseInputOptions |
Options for parseInput. |
UrlPolicyOptions |
Options for validateUrl. |
ValidationIssue |
A single validation problem with a dotted path into the offending data. |
ValidationResult |
Result of a validate* function. |
Variables
Section titled “Variables”| Name | Summary |
|---|---|
FORBIDDEN_URL_SCHEMES |
Schemes validateUrl always rejects: they run code or read local data. |
jsonObjectSchema |
A valibot schema for a JSON object (finite numbers, see jsonValueSchema). |
jsonValueSchema |
A valibot schema for a JSON value. Numbers must be finite: NaN and ±Infinity would silently serialise to null. |
KEY_SEGMENT_REGEX |
The characters allowed in a caller-supplied storage key segment. |