@nuxt-ignis/validation 0.0.1
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/LICENSE +21 -0
- package/README.md +24 -0
- package/dist/module.d.mts +10 -0
- package/dist/module.json +9 -0
- package/dist/module.mjs +31 -0
- package/dist/runtime/app/composables/useValibot.d.ts +10 -0
- package/dist/runtime/app/composables/useValibot.js +9 -0
- package/dist/runtime/app/composables/useZod.d.ts +11 -0
- package/dist/runtime/app/composables/useZod.js +9 -0
- package/dist/runtime/app/utils/validationValibot.d.ts +2 -0
- package/dist/runtime/app/utils/validationValibot.js +10 -0
- package/dist/runtime/app/utils/validationZod.d.ts +2 -0
- package/dist/runtime/app/utils/validationZod.js +9 -0
- package/dist/runtime/plugin.d.ts +2 -0
- package/dist/runtime/plugin.js +4 -0
- package/dist/runtime/server/tsconfig.json +3 -0
- package/dist/types.d.mts +3 -0
- package/package.json +63 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023-2025 Alois Sečkár
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# @nuxt-ignis/validation
|
|
2
|
+
|
|
3
|
+
[![npm version][npm-version-src]][npm-version-href]
|
|
4
|
+
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
|
5
|
+
[![License][license-src]][license-href]
|
|
6
|
+
[![Nuxt][nuxt-src]][nuxt-href]
|
|
7
|
+
|
|
8
|
+
Service module providing Validation features for Nuxt Ignis
|
|
9
|
+
|
|
10
|
+
See https://nuxt-ignis.com/
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
<!-- Badges -->
|
|
14
|
+
[npm-version-src]: https://img.shields.io/npm/v/@nuxt-ignis/validation/latest.svg?style=flat&colorA=020420&colorB=00DC82
|
|
15
|
+
[npm-version-href]: https://npmjs.com/package/@nuxt-ignis/validation
|
|
16
|
+
|
|
17
|
+
[npm-downloads-src]: https://img.shields.io/npm/dm/@nuxt-ignis/validation.svg?style=flat&colorA=020420&colorB=00DC82
|
|
18
|
+
[npm-downloads-href]: https://npm.chart.dev/@nuxt-ignis/validation
|
|
19
|
+
|
|
20
|
+
[license-src]: https://img.shields.io/npm/l/@nuxt-ignis/validation.svg?style=flat&colorA=020420&colorB=00DC82
|
|
21
|
+
[license-href]: https://npmjs.com/package/@nuxt-ignis/validation
|
|
22
|
+
|
|
23
|
+
[nuxt-src]: https://img.shields.io/badge/Nuxt-020420?logo=nuxt
|
|
24
|
+
[nuxt-href]: https://nuxt.com
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
|
|
3
|
+
interface ModuleOptions {
|
|
4
|
+
zod?: boolean;
|
|
5
|
+
valibot?: boolean;
|
|
6
|
+
}
|
|
7
|
+
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
8
|
+
|
|
9
|
+
export { _default as default };
|
|
10
|
+
export type { ModuleOptions };
|
package/dist/module.json
ADDED
package/dist/module.mjs
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { defineNuxtModule, createResolver, addImports, addPlugin } from '@nuxt/kit';
|
|
2
|
+
|
|
3
|
+
const module$1 = defineNuxtModule({
|
|
4
|
+
meta: {
|
|
5
|
+
name: "@nuxt-ignis/validation",
|
|
6
|
+
configKey: "ignisValidation"
|
|
7
|
+
},
|
|
8
|
+
setup(options, nuxt) {
|
|
9
|
+
const resolver = createResolver(import.meta.url);
|
|
10
|
+
nuxt.options.runtimeConfig.public.ignis ||= { zod: false, valibot: false };
|
|
11
|
+
nuxt.options.runtimeConfig.public.ignis.zod = options.zod || false;
|
|
12
|
+
nuxt.options.runtimeConfig.public.ignis.valibot = options.valibot || false;
|
|
13
|
+
if (options.zod === true) {
|
|
14
|
+
addImports([
|
|
15
|
+
{ name: "useZod", from: resolver.resolve("runtime/composables/useZod") },
|
|
16
|
+
{ name: "validateByZod", from: resolver.resolve("runtime/utils/validationZod") }
|
|
17
|
+
]);
|
|
18
|
+
console.debug("zod validation enabled");
|
|
19
|
+
}
|
|
20
|
+
if (options.valibot === true) {
|
|
21
|
+
addImports([
|
|
22
|
+
{ name: "useValibot", from: resolver.resolve("runtime/composables/useValibot") },
|
|
23
|
+
{ name: "validateByValibot", from: resolver.resolve("runtime/utils/validationValibot") }
|
|
24
|
+
]);
|
|
25
|
+
console.debug("valibot validation enabled");
|
|
26
|
+
}
|
|
27
|
+
addPlugin(resolver.resolve("./runtime/plugin"));
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export { module$1 as default };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type ValibotModule = typeof import('valibot');
|
|
2
|
+
/**
|
|
3
|
+
* Exposes Valibot schema validation functions. Requires `NUXT_PUBLIC_IGNIS_PRESET_VALIDATION=valibot` or `NUXT_PUBLIC_IGNIS_VALIBOT=true` to work properly.
|
|
4
|
+
*
|
|
5
|
+
* Usage: `const v = (await useValibot())!`
|
|
6
|
+
*
|
|
7
|
+
* @returns Valibot `v` object for schema validation
|
|
8
|
+
*/
|
|
9
|
+
export declare const useValibot: () => Promise<ValibotModule | undefined>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { useRuntimeConfig } from "#imports";
|
|
2
|
+
export const useValibot = async () => {
|
|
3
|
+
if (useRuntimeConfig().public.ignis.valibot === true) {
|
|
4
|
+
const valibot = await import("valibot");
|
|
5
|
+
return valibot;
|
|
6
|
+
} else {
|
|
7
|
+
console.warn("Valibot is not enabled (set NUXT_PUBLIC_IGNIS_PRESET_VALIDATION=valibot or NUXT_PUBLIC_IGNIS_VALIBOT=true)");
|
|
8
|
+
}
|
|
9
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type ZodModule = typeof import('zod/v4');
|
|
2
|
+
type ZodZ = ZodModule['z'];
|
|
3
|
+
/**
|
|
4
|
+
* Exposes Zod schema validation functions. Requires `NUXT_PUBLIC_IGNIS_PRESET_VALIDATION=zod` or `NUXT_PUBLIC_IGNIS_ZOD=true` to work properly.
|
|
5
|
+
*
|
|
6
|
+
* Usage: `const z = (await useZod())!`
|
|
7
|
+
*
|
|
8
|
+
* @returns Zod `z` object for schema validation
|
|
9
|
+
*/
|
|
10
|
+
export declare const useZod: () => Promise<ZodZ | undefined>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { useRuntimeConfig } from "#imports";
|
|
2
|
+
export const useZod = async () => {
|
|
3
|
+
if (useRuntimeConfig().public.ignis.zod === true) {
|
|
4
|
+
const zod = await import("zod/v4");
|
|
5
|
+
return zod.z;
|
|
6
|
+
} else {
|
|
7
|
+
console.warn("Zod is not enabled (set NUXT_PUBLIC_IGNIS_PRESET_VALIDATION=zod or NUXT_PUBLIC_IGNIS_ZOD=true)");
|
|
8
|
+
}
|
|
9
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useRuntimeConfig, useValibot } from "#imports";
|
|
2
|
+
export async function isValidByValibot(schema, obj) {
|
|
3
|
+
if (useRuntimeConfig().public.ignis.valibot === true) {
|
|
4
|
+
const v = await useValibot();
|
|
5
|
+
return v.safeParse(schema, obj).success;
|
|
6
|
+
} else {
|
|
7
|
+
console.warn("Valibot is not enabled (set NUXT_PUBLIC_IGNIS_PRESET_VALIDATION=valibot or NUXT_PUBLIC_IGNIS_VALIBOT=true)");
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { useRuntimeConfig } from "#imports";
|
|
2
|
+
export async function isValidByZod(schema, obj) {
|
|
3
|
+
if (useRuntimeConfig().public.ignis.zod === true) {
|
|
4
|
+
return schema.safeParse(obj).success;
|
|
5
|
+
} else {
|
|
6
|
+
console.warn("Zod is not enabled (set NUXT_PUBLIC_IGNIS_PRESET_VALIDATION=zod or NUXT_PUBLIC_IGNIS_ZOD=true)");
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
}
|
package/dist/types.d.mts
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nuxt-ignis/validation",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Nuxt Ignis module - Validation features",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/AloisSeckar/nuxt-ignis.git"
|
|
11
|
+
},
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"type": "module",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/types.d.mts",
|
|
17
|
+
"import": "./dist/module.mjs"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"main": "./dist/module.mjs",
|
|
21
|
+
"typesVersions": {
|
|
22
|
+
"*": {
|
|
23
|
+
".": [
|
|
24
|
+
"./dist/types.d.mts"
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist"
|
|
30
|
+
],
|
|
31
|
+
"workspaces": [
|
|
32
|
+
"playground"
|
|
33
|
+
],
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@nuxt/kit": "4.3.1"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@nuxt/devtools": "^3.1.1",
|
|
39
|
+
"@nuxt/eslint-config": "^1.14.0",
|
|
40
|
+
"@nuxt/module-builder": "^1.0.2",
|
|
41
|
+
"@nuxt/schema": "4.3.1",
|
|
42
|
+
"@nuxt/test-utils": "^4.0.0",
|
|
43
|
+
"@types/node": "^25.2.2",
|
|
44
|
+
"changelogen": "^0.6.2",
|
|
45
|
+
"eslint": "^9.39.2",
|
|
46
|
+
"nuxt": "4.3.1",
|
|
47
|
+
"typescript": "^5.9.3",
|
|
48
|
+
"valibot": "1.2.0",
|
|
49
|
+
"vitest": "^4.0.18",
|
|
50
|
+
"vue-tsc": "^3.2.4",
|
|
51
|
+
"zod": "4.3.6"
|
|
52
|
+
},
|
|
53
|
+
"scripts": {
|
|
54
|
+
"dev": "npm run dev:prepare && nuxt dev playground",
|
|
55
|
+
"dev:build": "nuxt build playground",
|
|
56
|
+
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxt prepare playground",
|
|
57
|
+
"release": "npm run lint && npm run test && npm run prepack && changelogen --release && npm publish && git push --follow-tags",
|
|
58
|
+
"lint": "eslint .",
|
|
59
|
+
"test": "vitest run",
|
|
60
|
+
"test:watch": "vitest watch",
|
|
61
|
+
"test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit"
|
|
62
|
+
}
|
|
63
|
+
}
|