docs: update portal for WRNexusJS 0.2.23

This commit is contained in:
2026-07-13 20:40:47 +05:30
parent a4f0e65bdc
commit 55438f2672
77 changed files with 551 additions and 523 deletions
+12 -6
View File
@@ -10,12 +10,12 @@ 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="/language">Language</a><a href="/architecture">Architecture</a></nav>
<div class="topbar-actions"><a class="preview-pill" href="/access">Private preview · v0.2.22</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.2.23</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="/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="page package-page">
<aside class="sidebar"><a href="/packages">← All packages</a><span class="category">Security</span><h2>@wrnexus/validation</h2><p>Typed schemas, coercion, validation, and browser descriptors.</p><span class="status status-beta">Private preview · 0.2.22</span><nav><a href="#access">Access</a><a href="#guide">Guide</a><a href="#api">Complete API</a></nav></aside>
<article id="main" class="documentation"><section class="doc-intro"><span class="eyebrow">Security · Preview</span><h1>@wrnexus/validation</h1><p>Typed schemas, coercion, validation, and browser descriptors.</p><section id="access" class="access-callout"><h2>Private registry access required</h2><p>This package is not available from the public npm registry. After WorkRoot approves access and supplies private registry instructions, install the release-aligned package:</p><pre><code>bun add @wrnexus/validation@0.2.22</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" class="prose"><blockquote>One fluent schema, validated on the server (API bodies, env vars) and mirrored to an eval-free browser validator for forms.</blockquote>
<aside class="sidebar"><a href="/packages">← All packages</a><span class="category">Security</span><h2>@wrnexus/validation</h2><p>Typed schemas, coercion, validation, and browser descriptors.</p><span class="status status-beta">Private preview · 0.2.23</span><nav><a href="#access">Access</a><a href="#guide">Guide</a><a href="#api">Complete API</a></nav></aside>
<article id="main" class="documentation"><section class="doc-intro"><span class="eyebrow">Security · Preview</span><h1>@wrnexus/validation</h1><p>Typed schemas, coercion, validation, and browser descriptors.</p><section id="access" class="access-callout"><h2>Private registry access required</h2><p>This package is not available from the public npm registry. After WorkRoot approves access and supplies private registry instructions, install the release-aligned package:</p><pre><code>bun add @wrnexus/validation@0.2.23</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" class="prose"><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>
@@ -31,6 +31,7 @@ page wrnexusvalidation {
<p>Every field schema is chainable and shares these base methods:</p>
<ul>
<li><code>min(n, message?)</code> / <code>max(n, message?)</code> — for strings, bounds the length; for numbers, bounds the value.</li>
<li><code>required(message?)</code> — require a non-empty value and optionally replace the default <code>&quot;Required&quot;</code> message on both server and browser validation.</li>
<li><code>optional()</code> — an empty/missing value passes instead of erroring <code>&quot;Required&quot;</code>.</li>
<li><code>label(text)</code> — human label carried into the descriptor.</li>
<li><code>default(value)</code> — value substituted when the field is absent (implies <code>optional</code>).</li>
@@ -86,8 +87,8 @@ VALIDATE_RUNTIME: string</code></pre>
<pre data-language="ts"><code>import &#123; v, parseBody &#125; from &quot;@wrnexus/validation&quot;;
export const signupSchema = v.object(&#123;
email: v.string().trim().email(),
password: v.string().min(8).max(200),
email: v.string().required(&quot;Enter your email address&quot;).trim().email(),
password: v.string().required(&quot;Enter your password&quot;).min(8).max(200),
age: v.number().integer().min(13).max(120).optional(),
role: v.string().oneOf([&quot;user&quot;, &quot;admin&quot;]).default(&quot;user&quot;),
agree: v.boolean(),
@@ -186,6 +187,8 @@ type RuleDescriptor = &#123;
interface FieldDescriptor &#123;
type: &quot;string&quot; | &quot;number&quot; | &quot;boolean&quot;;
optional?: boolean;
/** Message used when a required field is empty. Defaults to &quot;Required&quot;. */
requiredMessage?: string;
label?: string;
/** Trim string input before validating. */
trim?: boolean;
@@ -220,11 +223,14 @@ type Refinement = &#123;
declare abstract class FieldSchema &#123;
abstract readonly type: &quot;string&quot; | &quot;number&quot; | &quot;boolean&quot;;
protected _optional: boolean;
protected _requiredMessage?: string;
protected _label?: string;
protected _default?: unknown;
protected rules: RuleDescriptor[];
protected refinements: Refinement[];
optional(): this;
/** Require a non-empty value and optionally replace the default message. */
required(message?: string): this;
label(label: string): this;
/** Value used when the field is absent (implies optional). */
default(value: unknown): this;
@@ -311,7 +317,7 @@ schema.describe(): SchemaDescriptor</code></pre></article><article class="exampl
&#125;</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>WRNexusJS 0.2.22 · Private Developer Preview · Bun-native · Documentation generated from installed package APIs.</footer>
<footer>WRNexusJS 0.2.23 · Private Developer Preview · Bun-native · Documentation generated from installed package APIs.</footer>
</div>
}
}