feat: support custom required validation messages
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wrnexus/ai",
|
||||
"version": "0.2.22",
|
||||
"version": "0.2.23",
|
||||
"type": "module",
|
||||
"description": "Zero-dependency Claude (Anthropic) client for WrNexus apps.",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wrnexus/authz",
|
||||
"version": "0.2.22",
|
||||
"version": "0.2.23",
|
||||
"type": "module",
|
||||
"description": "@wrnexus/authz — part of the WrNexus framework.",
|
||||
"license": "MIT",
|
||||
|
||||
+11
-11
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wrnexus/cli",
|
||||
"version": "0.2.22",
|
||||
"version": "0.2.23",
|
||||
"type": "module",
|
||||
"description": "@wrnexus/cli — part of the WrNexus framework.",
|
||||
"license": "MIT",
|
||||
@@ -28,16 +28,16 @@
|
||||
"wrnexus": "./dist/index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@wrnexus/core": "^0.2.22",
|
||||
"@wrnexus/router": "^0.2.22",
|
||||
"@wrnexus/csr": "^0.2.22",
|
||||
"@wrnexus/compiler": "^0.2.22",
|
||||
"@wrnexus/styles": "^0.2.22",
|
||||
"@wrnexus/dev-server": "^0.2.22",
|
||||
"@wrnexus/ui": "^0.2.22",
|
||||
"@wrnexus/validation": "^0.2.22",
|
||||
"@wrnexus/i18n": "^0.2.22",
|
||||
"@wrnexus/db": "^0.2.22"
|
||||
"@wrnexus/core": "^0.2.23",
|
||||
"@wrnexus/router": "^0.2.23",
|
||||
"@wrnexus/csr": "^0.2.23",
|
||||
"@wrnexus/compiler": "^0.2.23",
|
||||
"@wrnexus/styles": "^0.2.23",
|
||||
"@wrnexus/dev-server": "^0.2.23",
|
||||
"@wrnexus/ui": "^0.2.23",
|
||||
"@wrnexus/validation": "^0.2.23",
|
||||
"@wrnexus/i18n": "^0.2.23",
|
||||
"@wrnexus/db": "^0.2.23"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wrnexus/compiler",
|
||||
"version": "0.2.22",
|
||||
"version": "0.2.23",
|
||||
"type": "module",
|
||||
"description": "@wrnexus/compiler — part of the WrNexus framework.",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wrnexus/core",
|
||||
"version": "0.2.22",
|
||||
"version": "0.2.23",
|
||||
"type": "module",
|
||||
"description": "@wrnexus/core — part of the WrNexus framework.",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wrnexus/csr",
|
||||
"version": "0.2.22",
|
||||
"version": "0.2.23",
|
||||
"type": "module",
|
||||
"description": "@wrnexus/csr — part of the WrNexus framework.",
|
||||
"license": "MIT",
|
||||
@@ -21,7 +21,7 @@
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@wrnexus/core": "^0.2.22"
|
||||
"@wrnexus/core": "^0.2.23"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wrnexus/db",
|
||||
"version": "0.2.22",
|
||||
"version": "0.2.23",
|
||||
"type": "module",
|
||||
"description": "@wrnexus/db — part of the WrNexus framework.",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wrnexus/dev-server",
|
||||
"version": "0.2.22",
|
||||
"version": "0.2.23",
|
||||
"type": "module",
|
||||
"description": "@wrnexus/dev-server — part of the WrNexus framework.",
|
||||
"license": "MIT",
|
||||
@@ -25,18 +25,18 @@
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@wrnexus/core": "^0.2.22",
|
||||
"@wrnexus/router": "^0.2.22",
|
||||
"@wrnexus/ssr": "^0.2.22",
|
||||
"@wrnexus/csr": "^0.2.22",
|
||||
"@wrnexus/compiler": "^0.2.22",
|
||||
"@wrnexus/styles": "^0.2.22",
|
||||
"@wrnexus/ui": "^0.2.22",
|
||||
"@wrnexus/validation": "^0.2.22",
|
||||
"@wrnexus/i18n": "^0.2.22",
|
||||
"@wrnexus/db": "^0.2.22",
|
||||
"@wrnexus/pubsub": "^0.2.22",
|
||||
"@wrnexus/uploader": "^0.2.22"
|
||||
"@wrnexus/core": "^0.2.23",
|
||||
"@wrnexus/router": "^0.2.23",
|
||||
"@wrnexus/ssr": "^0.2.23",
|
||||
"@wrnexus/csr": "^0.2.23",
|
||||
"@wrnexus/compiler": "^0.2.23",
|
||||
"@wrnexus/styles": "^0.2.23",
|
||||
"@wrnexus/ui": "^0.2.23",
|
||||
"@wrnexus/validation": "^0.2.23",
|
||||
"@wrnexus/i18n": "^0.2.23",
|
||||
"@wrnexus/db": "^0.2.23",
|
||||
"@wrnexus/pubsub": "^0.2.23",
|
||||
"@wrnexus/uploader": "^0.2.23"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wrnexus/encryption",
|
||||
"version": "0.2.22",
|
||||
"version": "0.2.23",
|
||||
"type": "module",
|
||||
"description": "@wrnexus/encryption — part of the WrNexus framework.",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wrnexus/helpers",
|
||||
"version": "0.2.22",
|
||||
"version": "0.2.23",
|
||||
"type": "module",
|
||||
"description": "Safe convenience helpers for WrNexus request contexts and common application flows.",
|
||||
"license": "MIT",
|
||||
@@ -21,7 +21,7 @@
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@wrnexus/core": "^0.2.22"
|
||||
"@wrnexus/core": "^0.2.23"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wrnexus/i18n",
|
||||
"version": "0.2.22",
|
||||
"version": "0.2.23",
|
||||
"type": "module",
|
||||
"description": "@wrnexus/i18n — part of the WrNexus framework.",
|
||||
"license": "MIT",
|
||||
@@ -21,7 +21,7 @@
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@wrnexus/core": "^0.2.22"
|
||||
"@wrnexus/core": "^0.2.23"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wrnexus/jwt",
|
||||
"version": "0.2.22",
|
||||
"version": "0.2.23",
|
||||
"type": "module",
|
||||
"description": "@wrnexus/jwt — part of the WrNexus framework.",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wrnexus/mobile",
|
||||
"version": "0.2.22",
|
||||
"version": "0.2.23",
|
||||
"type": "module",
|
||||
"description": "@wrnexus/mobile — part of the WrNexus framework.",
|
||||
"license": "MIT",
|
||||
@@ -21,7 +21,7 @@
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@wrnexus/native": "^0.2.22"
|
||||
"@wrnexus/native": "^0.2.23"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wrnexus/native",
|
||||
"version": "0.2.22",
|
||||
"version": "0.2.23",
|
||||
"type": "module",
|
||||
"description": "@wrnexus/native — part of the WrNexus framework.",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wrnexus/oauth",
|
||||
"version": "0.2.22",
|
||||
"version": "0.2.23",
|
||||
"type": "module",
|
||||
"description": "@wrnexus/oauth — part of the WrNexus framework.",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wrnexus/pubsub",
|
||||
"version": "0.2.22",
|
||||
"version": "0.2.23",
|
||||
"type": "module",
|
||||
"description": "@wrnexus/pubsub — part of the WrNexus framework.",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wrnexus/queue",
|
||||
"version": "0.2.22",
|
||||
"version": "0.2.23",
|
||||
"type": "module",
|
||||
"description": "@wrnexus/queue — part of the WrNexus framework.",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wrnexus/reactive",
|
||||
"version": "0.2.22",
|
||||
"version": "0.2.23",
|
||||
"type": "module",
|
||||
"description": "@wrnexus/reactive — part of the WrNexus framework.",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wrnexus/router",
|
||||
"version": "0.2.22",
|
||||
"version": "0.2.23",
|
||||
"type": "module",
|
||||
"description": "@wrnexus/router — part of the WrNexus framework.",
|
||||
"license": "MIT",
|
||||
@@ -21,8 +21,8 @@
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@wrnexus/compiler": "^0.2.22",
|
||||
"@wrnexus/core": "^0.2.22"
|
||||
"@wrnexus/compiler": "^0.2.23",
|
||||
"@wrnexus/core": "^0.2.23"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wrnexus/ssr",
|
||||
"version": "0.2.22",
|
||||
"version": "0.2.23",
|
||||
"type": "module",
|
||||
"description": "@wrnexus/ssr — part of the WrNexus framework.",
|
||||
"license": "MIT",
|
||||
@@ -21,7 +21,7 @@
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@wrnexus/core": "^0.2.22"
|
||||
"@wrnexus/core": "^0.2.23"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wrnexus/styles",
|
||||
"version": "0.2.22",
|
||||
"version": "0.2.23",
|
||||
"type": "module",
|
||||
"description": "@wrnexus/styles — part of the WrNexus framework.",
|
||||
"license": "MIT",
|
||||
@@ -21,7 +21,7 @@
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@wrnexus/uploader": "^0.2.22"
|
||||
"@wrnexus/uploader": "^0.2.23"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wrnexus/test",
|
||||
"version": "0.2.22",
|
||||
"version": "0.2.23",
|
||||
"type": "module",
|
||||
"description": "@wrnexus/test — part of the WrNexus framework.",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wrnexus/tracking",
|
||||
"version": "0.2.22",
|
||||
"version": "0.2.23",
|
||||
"type": "module",
|
||||
"description": "@wrnexus/tracking — part of the WrNexus framework.",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wrnexus/ui",
|
||||
"version": "0.2.22",
|
||||
"version": "0.2.23",
|
||||
"type": "module",
|
||||
"description": "@wrnexus/ui — part of the WrNexus framework.",
|
||||
"license": "MIT",
|
||||
@@ -22,7 +22,7 @@
|
||||
"./ui.css": "./ui.css"
|
||||
},
|
||||
"dependencies": {
|
||||
"@wrnexus/core": "^0.2.22"
|
||||
"@wrnexus/core": "^0.2.23"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wrnexus/uploader",
|
||||
"version": "0.2.22",
|
||||
"version": "0.2.23",
|
||||
"type": "module",
|
||||
"description": "@wrnexus/uploader — part of the WrNexus framework.",
|
||||
"license": "MIT",
|
||||
@@ -21,7 +21,7 @@
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@wrnexus/core": "^0.2.22"
|
||||
"@wrnexus/core": "^0.2.23"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
|
||||
@@ -35,6 +35,7 @@ import { v } from "@wrnexus/validation";
|
||||
Every field schema is chainable and shares these base methods:
|
||||
|
||||
- `min(n, message?)` / `max(n, message?)` — for strings, bounds the length; for numbers, bounds the value.
|
||||
- `required(message?)` — require a non-empty value and optionally replace the default `"Required"` message on both server and browser validation.
|
||||
- `optional()` — an empty/missing value passes instead of erroring `"Required"`.
|
||||
- `label(text)` — human label carried into the descriptor.
|
||||
- `default(value)` — value substituted when the field is absent (implies `optional`).
|
||||
@@ -121,8 +122,8 @@ Define a schema and validate an API body:
|
||||
import { v, parseBody } from "@wrnexus/validation";
|
||||
|
||||
export const signupSchema = v.object({
|
||||
email: v.string().trim().email(),
|
||||
password: v.string().min(8).max(200),
|
||||
email: v.string().required("Enter your email address").trim().email(),
|
||||
password: v.string().required("Enter your password").min(8).max(200),
|
||||
age: v.number().integer().min(13).max(120).optional(),
|
||||
role: v.string().oneOf(["user", "admin"]).default("user"),
|
||||
agree: v.boolean(),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wrnexus/validation",
|
||||
"version": "0.2.22",
|
||||
"version": "0.2.23",
|
||||
"type": "module",
|
||||
"description": "@wrnexus/validation — part of the WrNexus framework.",
|
||||
"license": "MIT",
|
||||
|
||||
Reference in New Issue
Block a user