@stone-js/validation 0.8.0 → 0.8.2
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/README.md +10 -3
- package/dist/index.js +16 -16
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
# Stone.js · Validation
|
|
2
2
|
|
|
3
|
-
[](https://opensource.org/licenses/MIT)
|
|
4
|
+
[](https://www.npmjs.com/package/@stone-js/validation)
|
|
5
|
+
[](https://www.npmjs.com/package/@stone-js/validation)
|
|
6
|
+

|
|
4
7
|
[](https://github.com/stone-foundation/stone-js-framework/actions/workflows/ci.yml)
|
|
5
|
-
[](https://github.com/stone-foundation/stone-js-framework/actions/workflows/release.yml)
|
|
9
|
+
[](https://sonarcloud.io/summary/new_code?id=stone-foundation_stone-js-framework)
|
|
10
|
+
[](https://sonarcloud.io/summary/new_code?id=stone-foundation_stone-js-framework)
|
|
11
|
+
[](https://github.com/stone-foundation/stone-js-framework/blob/main/SECURITY.md)
|
|
12
|
+
[](https://github.com/stone-foundation/stone-js-framework/security/code-scanning)
|
|
13
|
+
[](https://github.com/stone-foundation/stone-js-framework/network/updates)
|
|
7
14
|
[](https://conventionalcommits.org)
|
|
8
15
|
|
|
9
16
|
> Framework-agnostic input validation for Stone.js. Define a schema once (Zod, Valibot, ArkType — anything Standard Schema) and validate it identically on the backend and the frontend.
|
package/dist/index.js
CHANGED
|
@@ -105,7 +105,7 @@ function fromStandard(schema) {
|
|
|
105
105
|
*/
|
|
106
106
|
function isStandardSchema(value) {
|
|
107
107
|
const std = value?.['~standard'];
|
|
108
|
-
return std
|
|
108
|
+
return std?.version === 1 && typeof std?.validate === 'function';
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
/**
|
|
@@ -247,6 +247,21 @@ function validateEvent(event, rules, validator = Validator.create()) {
|
|
|
247
247
|
}
|
|
248
248
|
}
|
|
249
249
|
|
|
250
|
+
/**
|
|
251
|
+
* Opt-in blueprint: import and register it to enable validation.
|
|
252
|
+
*
|
|
253
|
+
* It contributes the validation service provider. `stone.providers` is an array, so this merges
|
|
254
|
+
* with the rest of the app rather than replacing anything.
|
|
255
|
+
*/
|
|
256
|
+
const validationBlueprint = {
|
|
257
|
+
stone: {
|
|
258
|
+
validation: {},
|
|
259
|
+
providers: [
|
|
260
|
+
ValidationServiceProvider
|
|
261
|
+
]
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
|
|
250
265
|
/**
|
|
251
266
|
* Builds a route middleware that validates the event's inputs before the handler runs.
|
|
252
267
|
*
|
|
@@ -268,19 +283,4 @@ function validate(rules) {
|
|
|
268
283
|
};
|
|
269
284
|
}
|
|
270
285
|
|
|
271
|
-
/**
|
|
272
|
-
* Opt-in blueprint: import and register it to enable validation.
|
|
273
|
-
*
|
|
274
|
-
* It contributes the validation service provider. `stone.providers` is an array, so this merges
|
|
275
|
-
* with the rest of the app rather than replacing anything.
|
|
276
|
-
*/
|
|
277
|
-
const validationBlueprint = {
|
|
278
|
-
stone: {
|
|
279
|
-
validation: {},
|
|
280
|
-
providers: [
|
|
281
|
-
ValidationServiceProvider
|
|
282
|
-
]
|
|
283
|
-
}
|
|
284
|
-
};
|
|
285
|
-
|
|
286
286
|
export { ValidationError, ValidationServiceProvider, Validator, fromStandard, fromZod, isNativeSchema, isStandardSchema, isZodLike, resolveSchema, validate, validateEvent, validationBlueprint };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stone-js/validation",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.2",
|
|
4
4
|
"description": "Framework-agnostic input validation for Stone.js. Define a schema once (Zod, Valibot, ArkType — anything Standard Schema) and validate it identically on the backend and the frontend.",
|
|
5
5
|
"author": "Mr. Stone <evensstone@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"node": ">=18.17.0"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@stone-js/core": "0.8.
|
|
43
|
+
"@stone-js/core": "0.8.2"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@commitlint/cli": "^19.8.1",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"typescript": "^5.6.3",
|
|
63
63
|
"vitest": "^3.2.4",
|
|
64
64
|
"zod": "^3.24.1",
|
|
65
|
-
"@stone-js/core": "0.8.
|
|
65
|
+
"@stone-js/core": "0.8.2"
|
|
66
66
|
},
|
|
67
67
|
"ts-standard": {
|
|
68
68
|
"globals": [
|