@lunora/values 1.0.0-alpha.2 → 1.0.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.mjs +3 -3
- package/dist/packem_shared/{DEFER_VALIDATION-B23I3ZdL.mjs → DEFER_VALIDATION-Cpy5SwBo.mjs} +1 -1
- package/dist/packem_shared/{ValidationError-DWWcFe37.mjs → ValidationError-CdSwhYHu.mjs} +4 -3
- package/dist/packem_shared/{isOrWrapsFromValidator-DJMAE0l9.mjs → isOrWrapsFromValidator-Bg1o5VFG.mjs} +4 -3
- package/package.json +5 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
|
+
import { LunoraError } from '@lunora/errors';
|
|
1
2
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
3
|
type ValidationPath = ReadonlyArray<number | string>;
|
|
3
4
|
/**
|
|
4
5
|
* Thrown by `validator.parse` (or returned inside `safeParse`) when input does
|
|
5
6
|
* not match the validator's shape. `path` walks from the root to the offending
|
|
6
7
|
* value, e.g. `["users", 0, "email"]`.
|
|
8
|
+
*
|
|
9
|
+
* A `LunoraError` subclass: carries `code: "VALIDATION_ERROR"` and `status: 400`
|
|
10
|
+
* so the runtime/DO transport mappers surface it structurally (a request that
|
|
11
|
+
* fails validation is a 400), while keeping the `name: "ValidationError"` and the
|
|
12
|
+
* `path`/`expected`/`received` diagnostics.
|
|
7
13
|
*/
|
|
8
|
-
declare class ValidationError extends
|
|
14
|
+
declare class ValidationError extends LunoraError {
|
|
9
15
|
readonly path: ValidationPath;
|
|
10
16
|
readonly expected: string;
|
|
11
17
|
readonly received: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
|
+
import { LunoraError } from '@lunora/errors';
|
|
1
2
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
3
|
type ValidationPath = ReadonlyArray<number | string>;
|
|
3
4
|
/**
|
|
4
5
|
* Thrown by `validator.parse` (or returned inside `safeParse`) when input does
|
|
5
6
|
* not match the validator's shape. `path` walks from the root to the offending
|
|
6
7
|
* value, e.g. `["users", 0, "email"]`.
|
|
8
|
+
*
|
|
9
|
+
* A `LunoraError` subclass: carries `code: "VALIDATION_ERROR"` and `status: 400`
|
|
10
|
+
* so the runtime/DO transport mappers surface it structurally (a request that
|
|
11
|
+
* fails validation is a 400), while keeping the `name: "ValidationError"` and the
|
|
12
|
+
* `path`/`expected`/`received` diagnostics.
|
|
7
13
|
*/
|
|
8
|
-
declare class ValidationError extends
|
|
14
|
+
declare class ValidationError extends LunoraError {
|
|
9
15
|
readonly path: ValidationPath;
|
|
10
16
|
readonly expected: string;
|
|
11
17
|
readonly received: string;
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { ValidationError, describeValue, formatPath } from './packem_shared/ValidationError-
|
|
1
|
+
export { ValidationError, describeValue, formatPath } from './packem_shared/ValidationError-CdSwhYHu.mjs';
|
|
2
2
|
export { jsonSchemaFromNode, objectSchemaFromNodes } from './packem_shared/jsonSchemaFromNode-weszUOQG.mjs';
|
|
3
3
|
export { argsToJsonSchema, toJsonSchema } from './packem_shared/argsToJsonSchema-DdHmmamC.mjs';
|
|
4
|
-
export { isOrWrapsFromValidator, optionalInner, v } from './packem_shared/isOrWrapsFromValidator-
|
|
5
|
-
export { DEFER_VALIDATION, installCompiledValidatorMap, parseValidatorMap } from './packem_shared/DEFER_VALIDATION-
|
|
4
|
+
export { isOrWrapsFromValidator, optionalInner, v } from './packem_shared/isOrWrapsFromValidator-Bg1o5VFG.mjs';
|
|
5
|
+
export { DEFER_VALIDATION, installCompiledValidatorMap, parseValidatorMap } from './packem_shared/DEFER_VALIDATION-Cpy5SwBo.mjs';
|
|
6
6
|
|
|
7
7
|
const VERSION = "0.0.0";
|
|
8
8
|
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import { LunoraError } from '@lunora/errors';
|
|
2
|
+
|
|
1
3
|
const MAX_DESCRIBED_LENGTH = 80;
|
|
2
4
|
const truncate = (text) => text.length > MAX_DESCRIBED_LENGTH ? `${text.slice(0, MAX_DESCRIBED_LENGTH)}…` : text;
|
|
3
|
-
class ValidationError extends
|
|
5
|
+
class ValidationError extends LunoraError {
|
|
4
6
|
path;
|
|
5
7
|
expected;
|
|
6
8
|
received;
|
|
7
9
|
constructor(message, options) {
|
|
8
|
-
super(message);
|
|
9
|
-
this.name = "ValidationError";
|
|
10
|
+
super("VALIDATION_ERROR", message, { name: "ValidationError" });
|
|
10
11
|
this.path = options.path;
|
|
11
12
|
this.expected = options.expected;
|
|
12
13
|
this.received = options.received;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LunoraError } from '@lunora/errors';
|
|
2
|
+
import { ValidationError, formatPath, describeValue } from './ValidationError-CdSwhYHu.mjs';
|
|
2
3
|
|
|
3
4
|
function fail(context, expected, received) {
|
|
4
5
|
const path = [...context.path];
|
|
@@ -264,7 +265,7 @@ const record = (keyValidator, valueValidator) => {
|
|
|
264
265
|
};
|
|
265
266
|
const union = (...members) => {
|
|
266
267
|
if (members.length === 0) {
|
|
267
|
-
throw new
|
|
268
|
+
throw new LunoraError("INTERNAL", "v.union requires at least one member");
|
|
268
269
|
}
|
|
269
270
|
const memberInternals = members.map((member) => toInternal(member));
|
|
270
271
|
return asColumn(
|
|
@@ -324,7 +325,7 @@ const standardIssuePath = (path) => {
|
|
|
324
325
|
const from = (schema) => {
|
|
325
326
|
const props = schema["~standard"];
|
|
326
327
|
if (props?.version !== 1 || typeof props.validate !== "function") {
|
|
327
|
-
throw new
|
|
328
|
+
throw new LunoraError("INTERNAL", '@lunora/values: v.from() expects a Standard Schema v1 object (missing or invalid "~standard")');
|
|
328
329
|
}
|
|
329
330
|
const validate = props.validate;
|
|
330
331
|
return asColumn(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/values",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.4",
|
|
4
4
|
"description": "Validators for Lunora: the v.* validator suite with end-to-end return-type inference",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"directory": "packages/values"
|
|
26
26
|
},
|
|
27
27
|
"files": [
|
|
28
|
-
"dist",
|
|
28
|
+
"./dist",
|
|
29
29
|
"README.md",
|
|
30
30
|
"LICENSE.md",
|
|
31
31
|
"__assets__"
|
|
@@ -45,6 +45,9 @@
|
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public"
|
|
47
47
|
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"@lunora/errors": "1.0.0-alpha.1"
|
|
50
|
+
},
|
|
48
51
|
"engines": {
|
|
49
52
|
"node": "^22.15.0 || >=24.11.0"
|
|
50
53
|
}
|