docs: update portal for WRnexusJS 0.5.0

This commit is contained in:
2026-07-29 13:18:08 +05:30
parent a09b791840
commit 19e20408db
164 changed files with 5578 additions and 1378 deletions
+17 -6
View File
@@ -10,11 +10,11 @@ page wrnexusvalidation {
<header class="topbar">
<a class="brand" href="/"><span>W</span> WRNexusJS</a>
<nav aria-label="Primary"><a href="/getting-started">Get started</a><a href="/packages">Packages</a><a href="/components">Components</a><a href="/language">Language</a><a href="/architecture">Architecture</a></nav>
<div class="topbar-actions"><a class="preview-pill" href="/access">Private preview · v0.4.0</a><button data-wire-theme-toggle class="theme-button" aria-label="Toggle color theme" title="Toggle color theme">◐</button></div>
<div class="topbar-actions"><a class="preview-pill" href="/access">Private preview · v0.5.0</a><button data-wire-theme-toggle class="theme-button" aria-label="Toggle color theme" title="Toggle color theme">◐</button></div>
</header>
<div class="mobile-doc-nav"><details><summary>Browse documentation</summary><nav><a href="/getting-started">Get started</a><a href="/packages">Packages</a><a href="/components">Components</a><a href="/language">Language</a><a href="/architecture">Architecture</a><a href="/tutorial">Tutorial</a><a href="/guides/project-structure">Guides</a><a href="/examples">Examples</a><a href="/search">Search</a></nav></details></div>
<main class="portal-main docs-layout">
<article id="main" class="documentation prose standalone package-document"><nav class="breadcrumbs" aria-label="Breadcrumb"><a href="/">Home</a><span>/</span><a href="/packages">Packages</a><span>/</span><span aria-current="page">@wrnexus/validation</span></nav><section class="doc-intro"><span class="eyebrow">Security · Package reference</span><h1>@wrnexus/validation</h1><p>Typed schemas, coercion, validation, and browser descriptors.</p><div class="doc-meta"><span>v0.4.0</span><span>Private registry</span><span>Security</span></div><section id="access" class="access-callout"><h2>Install the package</h2><p>After WorkRoot approves private registry access, install the release-aligned package:</p><pre><code>bun add @wrnexus/validation@0.4.0</code><button type="button" class="copy-button" aria-label="Copy installation command">Copy</button></pre><p><a href="/access">Request preview access</a>. Never put registry tokens in source control.</p></section></section><section id="guide"><blockquote>One fluent schema, validated on the server (API bodies, env vars) and mirrored to an eval-free browser validator for forms.</blockquote>
<article id="main" class="documentation prose standalone package-document"><nav class="breadcrumbs" aria-label="Breadcrumb"><a href="/">Home</a><span>/</span><a href="/packages">Packages</a><span>/</span><span aria-current="page">@wrnexus/validation</span></nav><section class="doc-intro"><span class="eyebrow">Security · Package reference</span><h1>@wrnexus/validation</h1><p>Typed schemas, coercion, validation, and browser descriptors.</p><div class="doc-meta"><span>v0.5.0</span><span>Private registry</span><span>Security</span></div><section id="access" class="access-callout"><h2>Install the package</h2><p>After WorkRoot approves private registry access, install the release-aligned package:</p><pre><code>bun add @wrnexus/validation@0.5.0</code><button type="button" class="copy-button" aria-label="Copy installation command">Copy</button></pre><p><a href="/access">Request preview access</a>. Never put registry tokens in source control.</p></section></section><section id="guide"><blockquote>One fluent schema, validated on the server (API bodies, env vars) and mirrored to an eval-free browser validator for forms.</blockquote>
<p>Part of the <strong>WRNexusJS</strong> framework — an SSR-first, Bun-native full-stack web framework.</p>
<h3 id="overview">Overview</h3>
<p>Define a schema once with the fluent <code>v</code> builder, then reuse it in three places: <code>.parse()</code> runs server-side and returns coerced values plus per-field errors; <code>.describe()</code> emits a plain-JSON <code>SchemaDescriptor</code> that the browser runtime interprets (no <code>eval</code>, no bundled validator); and helpers like <code>parseBody</code> and <code>parseEnv</code> wire schemas straight into API routes and startup config. The server rule logic (<code>applyRule</code>/<code>checkField</code>) and the client runtime (<code>VALIDATE_RUNTIME</code>) mirror each other exactly, so a form validates identically in both places. Schemas are conventionally kept in <code>app/schemas/</code>.</p>
@@ -214,7 +214,7 @@ type RuleDescriptor = &#123;
message?: string;
&#125;;
interface FieldDescriptor &#123;
type: &quot;string&quot; | &quot;number&quot; | &quot;boolean&quot;;
type: &quot;string&quot; | &quot;number&quot; | &quot;boolean&quot; | &quot;unknown&quot;;
optional?: boolean;
/** Message used when a required field is empty. Defaults to &quot;Required&quot;. */
requiredMessage?: string;
@@ -250,7 +250,7 @@ type Refinement = &#123;
message?: string;
&#125;;
declare abstract class FieldSchema &#123;
abstract readonly type: &quot;string&quot; | &quot;number&quot; | &quot;boolean&quot;;
abstract readonly type: &quot;string&quot; | &quot;number&quot; | &quot;boolean&quot; | &quot;unknown&quot;;
protected _optional: boolean;
protected _requiredMessage?: string;
protected _label?: string;
@@ -296,9 +296,19 @@ declare class NumberSchema extends FieldSchema &#123;
declare class BooleanSchema extends FieldSchema &#123;
readonly type: &quot;boolean&quot;;
&#125;
declare class UnknownSchema extends FieldSchema &#123;
readonly type: &quot;unknown&quot;;
&#125;
type AnyFieldSchema = StringSchema | NumberSchema | BooleanSchema | UnknownSchema;
declare class ObjectSchema &#123;
private readonly fields;
constructor(fields: Record&lt;string, FieldSchema&gt;);
/** Return a defensive copy of the schema fields. */
getFields(): Readonly&lt;Record&lt;string, FieldSchema&gt;&gt;;
/** Create a new schema with fields added or replaced. The original is unchanged. */
extend(fields: Record&lt;string, FieldSchema&gt;): ObjectSchema;
/** Create a new schema containing fields from both schemas. */
merge(schema: ObjectSchema): ObjectSchema;
/** Validate an input object; returns coerced values + per-field errors. */
parse(input: unknown): ParseResult;
describe(): SchemaDescriptor;
@@ -308,6 +318,7 @@ declare const v: &#123;
string: () =&gt; StringSchema;
number: () =&gt; NumberSchema;
boolean: () =&gt; BooleanSchema;
unknown: () =&gt; UnknownSchema;
object: (fields: Record&lt;string, FieldSchema&gt;) =&gt; ObjectSchema;
&#125;;
/**
@@ -337,7 +348,7 @@ declare function parseBody&lt;T = Record&lt;string, unknown&gt;&gt;(schema: Obje
response: Response;
&#125;&gt;;
export &#123; AsyncObjectSchema, type AsyncRefinement, type AsyncValidationContext, type FieldDescriptor, ObjectSchema, type OpenApiSchema, type ParseResult, type RuleDescriptor, type SchemaDescriptor, VALIDATE_RUNTIME, applyRule, asyncSchema, checkField, invalid, mergeValidationResults, parseBody, parseBodyAsync, parseEnv, renderSchemasScript, schemaToOpenApi, v &#125;;
export &#123; type AnyFieldSchema, AsyncObjectSchema, type AsyncRefinement, type AsyncValidationContext, BooleanSchema, type FieldDescriptor, FieldSchema, NumberSchema, ObjectSchema, type OpenApiSchema, type ParseResult, type RuleDescriptor, type SchemaDescriptor, StringSchema, UnknownSchema, VALIDATE_RUNTIME, applyRule, asyncSchema, checkField, invalid, mergeValidationResults, parseBody, parseBodyAsync, parseEnv, renderSchemasScript, schemaToOpenApi, v &#125;;
</code></pre></section><section id="examples" class="examples"><h2>Examples</h2><p>Copy-ready examples from the installed package documentation.</p><div class="example-grid"><article class="example-card"><h3>Define a schema and validate an API body</h3><pre data-language="ts"><code>import &#123; v, parseBody &#125; from &quot;@wrnexus/validation&quot;;
export const signupSchema = v.object(&#123;
@@ -373,7 +384,7 @@ const head = `&lt;script&gt;$&#123;renderSchemasScript(&#123; signup: signupSche
// render a &lt;form data-schema=&quot;signup&quot;&gt; with [data-error=&quot;email&quot;] etc.</code></pre></article></div></section></article>
<aside class="on-this-page"><h2>On this page</h2><nav><a class="toc-level-2" href="#guide">Guide</a><a class="toc-level-3" href="#overview">Overview</a><a class="toc-level-3" href="#api">API</a><a class="toc-level-4" href="#the-v-builder">The v builder</a><a class="toc-level-4" href="#objectschema">ObjectSchema</a><a class="toc-level-4" href="#rules-and-coercion">Rules and coercion</a><a class="toc-level-4" href="#api-helpers">API helpers</a><a class="toc-level-4" href="#environment-config">Environment config</a><a class="toc-level-4" href="#client-runtime-from-runtime-ts">Client runtime (from runtime.ts)</a><a class="toc-level-3" href="#usage">Usage</a><a class="toc-level-3" href="#requirements-notes">Requirements / Notes</a><a class="toc-level-2" href="#api">Complete API</a><a class="toc-level-2" href="#examples">Examples</a></nav></aside>
</main>
<footer><div class="footer-brand"><span class="footer-mark" aria-hidden="true">W</span><p><strong>WRNexusJS 0.4.0</strong><span>Complete API documentation generated from installed package declarations.</span></p></div><nav aria-label="Footer"><a href="/packages">All packages</a><a href="/getting-started">Get started</a><a href="/security">Security</a><a href="/support">Support</a><a href="/llms.txt">AI guide</a></nav><p class="footer-meta">Private Developer Preview · Bun-native</p></footer>
<footer><div class="footer-brand"><span class="footer-mark" aria-hidden="true">W</span><p><strong>WRNexusJS 0.5.0</strong><span>Complete API documentation generated from installed package declarations.</span></p></div><nav aria-label="Footer"><a href="/packages">All packages</a><a href="/getting-started">Get started</a><a href="/security">Security</a><a href="/support">Support</a><a href="/llms.txt">AI guide</a></nav><p class="footer-meta">Private Developer Preview · Bun-native</p></footer>
<BackToTop />
</div>
}