@veloxts/validation 0.6.26 → 0.6.29

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +515 -0
  2. package/GUIDE.md +216 -0
  3. package/package.json +6 -3
package/CHANGELOG.md ADDED
@@ -0,0 +1,515 @@
1
+ # @veloxts/validation
2
+
3
+ ## 0.6.29
4
+
5
+ ### Patch Changes
6
+
7
+ - add multi-tenancy and PostgreSQL support - test and lint fix
8
+ - Updated dependencies
9
+ - @veloxts/core@0.6.29
10
+
11
+ ## 0.6.28
12
+
13
+ ### Patch Changes
14
+
15
+ - add multi-tenancy support and postgresql database
16
+ - Updated dependencies
17
+ - @veloxts/core@0.6.28
18
+
19
+ ## 0.6.27
20
+
21
+ ### Patch Changes
22
+
23
+ - chore: add GUIDE, LICENSE and CHANGELOG.md to npm files
24
+ - Updated dependencies
25
+ - @veloxts/core@0.6.27
26
+
27
+ ## 0.6.26
28
+
29
+ ### Patch Changes
30
+
31
+ - docs(mcp): add README and GUIDE, docs(web): simplify README and create concise GUIDE
32
+ - Updated dependencies
33
+ - @veloxts/core@0.6.26
34
+
35
+ ## 0.6.25
36
+
37
+ ### Patch Changes
38
+
39
+ - docs(create): add guide for React Server Components setup
40
+ - Updated dependencies
41
+ - @veloxts/core@0.6.25
42
+
43
+ ## 0.6.24
44
+
45
+ ### Patch Changes
46
+
47
+ - clarify installation paths and package contents
48
+ - Updated dependencies
49
+ - @veloxts/core@0.6.24
50
+
51
+ ## 0.6.23
52
+
53
+ ### Patch Changes
54
+
55
+ - add defineContract for improved type inference DX
56
+ - Updated dependencies
57
+ - @veloxts/core@0.6.23
58
+
59
+ ## 0.6.22
60
+
61
+ ### Patch Changes
62
+
63
+ - support {method, path} route entry format
64
+ - Updated dependencies
65
+ - @veloxts/core@0.6.22
66
+
67
+ ## 0.6.21
68
+
69
+ ### Patch Changes
70
+
71
+ - separate schemas from procedures for browser-safe import
72
+ - Updated dependencies
73
+ - @veloxts/core@0.6.21
74
+
75
+ ## 0.6.20
76
+
77
+ ### Patch Changes
78
+
79
+ - add Fastify ecosystem stubs and debuglog to util
80
+ - Updated dependencies
81
+ - @veloxts/core@0.6.20
82
+
83
+ ## 0.6.19
84
+
85
+ ### Patch Changes
86
+
87
+ - restore dotenv stub for browser compatibility
88
+ - Updated dependencies
89
+ - @veloxts/core@0.6.19
90
+
91
+ ## 0.6.18
92
+
93
+ ### Patch Changes
94
+
95
+ - add node:fs/promises stub and fix esbuild plugin
96
+ - Updated dependencies
97
+ - @veloxts/core@0.6.18
98
+
99
+ ## 0.6.17
100
+
101
+ ### Patch Changes
102
+
103
+ - remove optimizeDeps.exclude to fix CJS/ESM interop
104
+ - Updated dependencies
105
+ - @veloxts/core@0.6.17
106
+
107
+ ## 0.6.16
108
+
109
+ ### Patch Changes
110
+
111
+ - add stubs for Fastify ecosystem packages
112
+ - Updated dependencies
113
+ - @veloxts/core@0.6.16
114
+
115
+ ## 0.6.15
116
+
117
+ ### Patch Changes
118
+
119
+ - implement three-layer Node.js stubbing for Vite
120
+ - Updated dependencies
121
+ - @veloxts/core@0.6.15
122
+
123
+ ## 0.6.14
124
+
125
+ ### Patch Changes
126
+
127
+ - stub dotenv as virtual module instead of process shims
128
+ - Updated dependencies
129
+ - @veloxts/core@0.6.14
130
+
131
+ ## 0.6.13
132
+
133
+ ### Patch Changes
134
+
135
+ - add process.argv stub for dotenv browser compatibility
136
+ - Updated dependencies
137
+ - @veloxts/core@0.6.13
138
+
139
+ ## 0.6.12
140
+
141
+ ### Patch Changes
142
+
143
+ - Fixes the "process is not defined" error from dotenv
144
+ - Updated dependencies
145
+ - @veloxts/core@0.6.12
146
+
147
+ ## 0.6.11
148
+
149
+ ### Patch Changes
150
+
151
+ - add Vite plugin for Node.js module stubs
152
+ - Updated dependencies
153
+ - @veloxts/core@0.6.11
154
+
155
+ ## 0.6.10
156
+
157
+ ### Patch Changes
158
+
159
+ - use import() type syntax for AppRouter
160
+ - Updated dependencies
161
+ - @veloxts/core@0.6.10
162
+
163
+ ## 0.6.9
164
+
165
+ ### Patch Changes
166
+
167
+ - isolate auth procedures from database imports
168
+ - Updated dependencies
169
+ - @veloxts/core@0.6.9
170
+
171
+ ## 0.6.8
172
+
173
+ ### Patch Changes
174
+
175
+ - prevent dotenv from leaking into browser bundle
176
+ - Updated dependencies
177
+ - @veloxts/core@0.6.8
178
+
179
+ ## 0.6.7
180
+
181
+ ### Patch Changes
182
+
183
+ - better-sqlite3 versions mismatch fix
184
+ - Updated dependencies
185
+ - @veloxts/core@0.6.7
186
+
187
+ ## 0.6.6
188
+
189
+ ### Patch Changes
190
+
191
+ - ensure the web app never imports server-side code paths
192
+ - Updated dependencies
193
+ - @veloxts/core@0.6.6
194
+
195
+ ## 0.6.5
196
+
197
+ ### Patch Changes
198
+
199
+ - move @prisma/client-runtime-utils to root package.json
200
+ - Updated dependencies
201
+ - @veloxts/core@0.6.5
202
+
203
+ ## 0.6.4
204
+
205
+ ### Patch Changes
206
+
207
+ - add @prisma/client-runtime-utils dependency
208
+ - Updated dependencies
209
+ - @veloxts/core@0.6.4
210
+
211
+ ## 0.6.3
212
+
213
+ ### Patch Changes
214
+
215
+ - Add workspaces field to root package.json template + Fix Prisma ESM/CJS import for Node.js v24
216
+ - Updated dependencies
217
+ - @veloxts/core@0.6.3
218
+
219
+ ## 0.6.2
220
+
221
+ ### Patch Changes
222
+
223
+ - add server actions, removed some deprecated and other chore
224
+ - Updated dependencies
225
+ - @veloxts/core@0.6.2
226
+
227
+ ## 0.6.1
228
+
229
+ ### Patch Changes
230
+
231
+ - route groups for file-based routing; add dynamic route support with [param] segments
232
+ - Updated dependencies
233
+ - @veloxts/core@0.6.1
234
+
235
+ ## 0.6.0
236
+
237
+ ### Minor Changes
238
+
239
+ - RSC streaming, dynamic routes, Vinxi integration
240
+
241
+ ### Patch Changes
242
+
243
+ - Updated dependencies
244
+ - @veloxts/core@0.6.0
245
+
246
+ ## 0.5.0
247
+
248
+ ### Minor Changes
249
+
250
+ - Auto-register procedures + inject Prisma models feature
251
+
252
+ ### Patch Changes
253
+
254
+ - Updated dependencies
255
+ - @veloxts/core@0.5.0
256
+
257
+ ## 0.4.21
258
+
259
+ ### Patch Changes
260
+
261
+ - format Prisma default values correctly by type
262
+ - Updated dependencies
263
+ - @veloxts/core@0.4.21
264
+
265
+ ## 0.4.20
266
+
267
+ ### Patch Changes
268
+
269
+ - import consolidation: update import paths for `@veloxts/velox`
270
+ - Updated dependencies
271
+ - @veloxts/core@0.4.20
272
+
273
+ ## 0.4.19
274
+
275
+ ### Patch Changes
276
+
277
+ - update default dev server port to 3030
278
+ - Updated dependencies
279
+ - @veloxts/core@0.4.19
280
+
281
+ ## 0.4.18
282
+
283
+ ### Patch Changes
284
+
285
+ - introduce interactive field menu and templates for resource generation
286
+ - Updated dependencies
287
+ - @veloxts/core@0.4.18
288
+
289
+ ## 0.4.17
290
+
291
+ ### Patch Changes
292
+
293
+ - add interactive field prompts for resource generation
294
+ - Updated dependencies
295
+ - @veloxts/core@0.4.17
296
+
297
+ ## 0.4.16
298
+
299
+ ### Patch Changes
300
+
301
+ - fixed velox procedures list
302
+ - Updated dependencies
303
+ - @veloxts/core@0.4.16
304
+
305
+ ## 0.4.15
306
+
307
+ ### Patch Changes
308
+
309
+ - chore lint fixes
310
+ - Updated dependencies
311
+ - @veloxts/core@0.4.15
312
+
313
+ ## 0.4.14
314
+
315
+ ### Patch Changes
316
+
317
+ - fixed proxy-type inferance and update proxy hooks for optional input handling
318
+ - Updated dependencies
319
+ - @veloxts/core@0.4.14
320
+
321
+ ## 0.4.13
322
+
323
+ ### Patch Changes
324
+
325
+ - add debug mode to dev server
326
+ - Updated dependencies
327
+ - @veloxts/core@0.4.13
328
+
329
+ ## 0.4.12
330
+
331
+ ### Patch Changes
332
+
333
+ - preserve type info in trpc template AppRouter export
334
+ - Updated dependencies
335
+ - @veloxts/core@0.4.12
336
+
337
+ ## 0.4.11
338
+
339
+ ### Patch Changes
340
+
341
+ - fixed api.health.check.useQuery is not a function issue
342
+ - Updated dependencies
343
+ - @veloxts/core@0.4.11
344
+
345
+ ## 0.4.10
346
+
347
+ ### Patch Changes
348
+
349
+ - fixed ReferenceError: styles is not defined in rpc template
350
+ - Updated dependencies
351
+ - @veloxts/core@0.4.10
352
+
353
+ ## 0.4.7
354
+
355
+ ### Patch Changes
356
+
357
+ - Add dynamic headers and routes config to client
358
+ - Updated dependencies
359
+ - @veloxts/core@0.4.7
360
+
361
+ ## 0.4.6
362
+
363
+ ### Patch Changes
364
+
365
+ - Fix broken npm packages - republish with correct dependencies
366
+ - Updated dependencies
367
+ - @veloxts/core@0.4.6
368
+
369
+ ## 0.4.5
370
+
371
+ ### Patch Changes
372
+
373
+ - b06631b: CI CD npm Trusted Publishing setup
374
+ - Updated dependencies [b06631b]
375
+ - @veloxts/core@0.4.5
376
+
377
+ ## 0.4.4
378
+
379
+ ### Patch Changes
380
+
381
+ - 05ae1a5: Update to boilerplate, work in progress
382
+ - 9961b52: full-stack React frontend implementation
383
+ - Updated dependencies [05ae1a5]
384
+ - Updated dependencies [9961b52]
385
+ - @veloxts/core@0.4.4
386
+
387
+ ## 0.4.3
388
+
389
+ ### Patch Changes
390
+
391
+ - ef8d5d0: Dynamically load VeloxTS version from `package.json` in shared template configuration
392
+ - Updated dependencies [ef8d5d0]
393
+ - @veloxts/core@0.4.3
394
+
395
+ ## 0.4.2
396
+
397
+ ### Patch Changes
398
+
399
+ - 5b4f02c: Updated documentations
400
+ - 0d8d775: Updated guides and readme files
401
+ - Updated dependencies [5b4f02c]
402
+ - Updated dependencies [0d8d775]
403
+ - @veloxts/core@0.4.2
404
+
405
+ ## 0.4.1
406
+
407
+ ### Patch Changes
408
+
409
+ - 0eea918: Completed CLI generators
410
+ - Updated dependencies [0eea918]
411
+ - @veloxts/core@0.4.1
412
+
413
+ ## 0.4.0
414
+
415
+ ### Minor Changes
416
+
417
+ - b478fee: Performance Benchmarks | 34k req/s, <1ms p50 latency, 75MB memory, 530ms startup
418
+
419
+ ### Patch Changes
420
+
421
+ - Updated dependencies [b478fee]
422
+ - @veloxts/core@0.4.0
423
+
424
+ ## 0.3.6
425
+
426
+ ### Patch Changes
427
+
428
+ - 929f2ab: Interactive CLI setup
429
+ - Updated dependencies [929f2ab]
430
+ - @veloxts/core@0.3.6
431
+
432
+ ## 0.3.5
433
+
434
+ ### Patch Changes
435
+
436
+ - 658e83f: @veloxts/auth, Full REST Support, Better error messages, Type tests with tsd
437
+ - Updated dependencies [658e83f]
438
+ - @veloxts/core@0.3.5
439
+
440
+ ## 0.3.4
441
+
442
+ ### Patch Changes
443
+
444
+ - 65ef3e7: DI container and Auth Guards
445
+ - Updated dependencies [65ef3e7]
446
+ - @veloxts/core@0.3.4
447
+
448
+ ## 0.3.3
449
+
450
+ ### Patch Changes
451
+
452
+ - 4ee103b: Full REST support PUT, PATCH and DELETE
453
+ - Updated dependencies [4ee103b]
454
+ - @veloxts/core@0.3.3
455
+
456
+ ## 0.3.2
457
+
458
+ ### Patch Changes
459
+
460
+ - abf270e: Dynamically set core `VELOX_VERSION` from package.json
461
+ - Updated dependencies [abf270e]
462
+ - @veloxts/core@0.3.2
463
+
464
+ ## 0.3.1
465
+
466
+ ### Patch Changes
467
+
468
+ - cb9806e: Fixed the value for VELOXTS_VERSION in create app template
469
+ - Updated dependencies [cb9806e]
470
+ - @veloxts/core@0.3.1
471
+
472
+ ## 0.3.0
473
+
474
+ ### Minor Changes
475
+
476
+ - 1adce10: Introduced an umbrella package for server side packages: @veloxts/velox
477
+
478
+ ### Patch Changes
479
+
480
+ - Updated dependencies [1adce10]
481
+ - @veloxts/core@0.3.0
482
+
483
+ ## 0.2.2
484
+
485
+ ### Patch Changes
486
+
487
+ - Version bump to sync with create-velox-app native module fix
488
+ - Updated dependencies
489
+ - @veloxts/core@0.2.2
490
+
491
+ ## 0.2.0
492
+
493
+ ### Minor Changes
494
+
495
+ - 9404976: fix Prisma client generation. README adjustments
496
+
497
+ ### Patch Changes
498
+
499
+ - Updated dependencies [9404976]
500
+ - @veloxts/core@0.2.0
501
+
502
+ ## 0.1.1
503
+
504
+ ### Patch Changes
505
+
506
+ - Fix Prisma client generation in scaffolder
507
+
508
+ - Added automatic Prisma client generation after dependency installation in create-velox-app
509
+ - Fixed database template to validate DATABASE_URL environment variable
510
+ - Added alpha release warning to all package READMEs
511
+ - Fixed TypeScript type for registerTRPCPlugin to accept FastifyInstance
512
+ - Updated playground app to use Prisma 7.x custom output path
513
+
514
+ - Updated dependencies
515
+ - @veloxts/core@0.1.1
package/GUIDE.md ADDED
@@ -0,0 +1,216 @@
1
+ # @veloxts/validation
2
+
3
+ Type-safe validation using Zod schemas for VeloxTS Framework.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @veloxts/validation
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import { z, parse } from '@veloxts/validation';
15
+
16
+ const UserSchema = z.object({
17
+ id: z.string().uuid(),
18
+ name: z.string().min(1),
19
+ email: z.string().email(),
20
+ });
21
+
22
+ const user = parse(UserSchema, untrustedData);
23
+ // user is validated and typed
24
+ ```
25
+
26
+ ## Validation Functions
27
+
28
+ ### parse()
29
+
30
+ Parse and validate data, throwing `ValidationError` if invalid:
31
+
32
+ ```typescript
33
+ import { parse, ValidationError } from '@veloxts/validation';
34
+
35
+ try {
36
+ const user = parse(UserSchema, data);
37
+ } catch (error) {
38
+ if (error instanceof ValidationError) {
39
+ console.log(error.fields); // Field-specific errors
40
+ }
41
+ }
42
+ ```
43
+
44
+ ### safeParse()
45
+
46
+ Validate without throwing, returns result object:
47
+
48
+ ```typescript
49
+ import { safeParse } from '@veloxts/validation';
50
+
51
+ const result = safeParse(UserSchema, data);
52
+
53
+ if (result.success) {
54
+ console.log(result.data);
55
+ } else {
56
+ console.log(result.error.issues);
57
+ }
58
+ ```
59
+
60
+ ## Common Schemas
61
+
62
+ Pre-built schemas for common use cases:
63
+
64
+ ```typescript
65
+ import {
66
+ uuidSchema,
67
+ emailSchema,
68
+ urlSchema,
69
+ nonEmptyStringSchema,
70
+ datetimeSchema,
71
+ idParamSchema,
72
+ } from '@veloxts/validation';
73
+
74
+ const id = parse(uuidSchema, '123e4567-...');
75
+ const email = parse(emailSchema, 'user@example.com');
76
+ const url = parse(urlSchema, 'https://example.com');
77
+ const name = parse(nonEmptyStringSchema, ' Alice '); // "Alice"
78
+ ```
79
+
80
+ ## Pagination
81
+
82
+ Built-in pagination support:
83
+
84
+ ```typescript
85
+ import {
86
+ paginationInputSchema,
87
+ createPaginatedResponseSchema,
88
+ calculatePaginationMeta,
89
+ } from '@veloxts/validation';
90
+
91
+ const input = parse(paginationInputSchema, {
92
+ page: 1,
93
+ limit: 20, // Default: 10, max: 100
94
+ });
95
+
96
+ const UserListSchema = createPaginatedResponseSchema(UserSchema);
97
+
98
+ const meta = calculatePaginationMeta({
99
+ page: 1,
100
+ limit: 10,
101
+ total: 95,
102
+ });
103
+ // { page: 1, limit: 10, total: 95, totalPages: 10, hasNext: true, hasPrev: false }
104
+ ```
105
+
106
+ ## Schema Utilities
107
+
108
+ Manipulate schemas:
109
+
110
+ ```typescript
111
+ import { pickFields, omitFields, makePartial, partialExcept } from '@veloxts/validation';
112
+
113
+ const UserSchema = z.object({
114
+ id: z.string().uuid(),
115
+ name: z.string(),
116
+ email: z.string().email(),
117
+ password: z.string(),
118
+ });
119
+
120
+ const PublicUserSchema = pickFields(UserSchema, ['id', 'name', 'email']);
121
+ const SafeUserSchema = omitFields(UserSchema, ['password']);
122
+ const PartialUserSchema = makePartial(UserSchema);
123
+ const UpdateSchema = partialExcept(UserSchema, ['id']);
124
+ ```
125
+
126
+ ## String Coercion
127
+
128
+ Parse string inputs to other types:
129
+
130
+ ```typescript
131
+ import {
132
+ numberStringSchema,
133
+ integerStringSchema,
134
+ booleanStringSchema,
135
+ } from '@veloxts/validation';
136
+
137
+ const age = parse(numberStringSchema, '25'); // 25 (number)
138
+ const count = parse(integerStringSchema, '42'); // 42 (number)
139
+ const enabled = parse(booleanStringSchema, 'true'); // true (boolean)
140
+ ```
141
+
142
+ ## Type Inference
143
+
144
+ Extract TypeScript types from schemas:
145
+
146
+ ```typescript
147
+ import { InferInput, InferOutput } from '@veloxts/validation';
148
+
149
+ const UserSchema = z.object({
150
+ email: z.string().email(),
151
+ age: z.number().transform((n) => n + 1),
152
+ });
153
+
154
+ type UserInput = InferInput<typeof UserSchema>;
155
+ // { email: string; age: number }
156
+
157
+ type UserOutput = InferOutput<typeof UserSchema>;
158
+ // { email: string; age: number } (after transform)
159
+ ```
160
+
161
+ ## Using with Procedures
162
+
163
+ Validation integrates seamlessly with VeloxTS procedures:
164
+
165
+ ```typescript
166
+ import { procedure, procedures } from '@veloxts/router';
167
+ import { z, emailSchema, nonEmptyStringSchema } from '@veloxts/validation';
168
+
169
+ const CreateUserInput = z.object({
170
+ name: nonEmptyStringSchema,
171
+ email: emailSchema,
172
+ age: z.number().int().min(18).optional(),
173
+ });
174
+
175
+ export const userProcedures = procedures('users', {
176
+ createUser: procedure()
177
+ .input(CreateUserInput)
178
+ .output(UserSchema)
179
+ .mutation(async ({ input, ctx }) => {
180
+ // input is validated and typed
181
+ return ctx.db.user.create({ data: input });
182
+ }),
183
+ });
184
+ ```
185
+
186
+ ## Error Handling
187
+
188
+ Validation errors include field-level details:
189
+
190
+ ```typescript
191
+ import { ValidationError, parse } from '@veloxts/validation';
192
+
193
+ try {
194
+ parse(UserSchema, invalidData);
195
+ } catch (error) {
196
+ if (error instanceof ValidationError) {
197
+ console.log(error.statusCode); // 400
198
+ console.log(error.fields);
199
+ // {
200
+ // name: "String must contain at least 2 character(s)",
201
+ // email: "Invalid email"
202
+ // }
203
+ }
204
+ }
205
+ ```
206
+
207
+ ## Learn More
208
+
209
+ - [@veloxts/core](https://www.npmjs.com/package/@veloxts/core) - Error classes
210
+ - [@veloxts/router](https://www.npmjs.com/package/@veloxts/router) - Procedure definitions
211
+ - [@veloxts/client](https://www.npmjs.com/package/@veloxts/client) - Type-safe client
212
+ - [VeloxTS Framework](https://www.npmjs.com/package/@veloxts/velox) - Complete framework
213
+
214
+ ## License
215
+
216
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veloxts/validation",
3
- "version": "0.6.26",
3
+ "version": "0.6.29",
4
4
  "description": "Zod integration and validation middleware for VeloxTS framework",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "zod": "3.25.76",
26
- "@veloxts/core": "0.6.26"
26
+ "@veloxts/core": "0.6.29"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@vitest/coverage-v8": "4.0.16",
@@ -40,7 +40,10 @@
40
40
  },
41
41
  "files": [
42
42
  "dist",
43
- "README.md"
43
+ "README.md",
44
+ "GUIDE.md",
45
+ "LICENSE",
46
+ "CHANGELOG.md"
44
47
  ],
45
48
  "keywords": [
46
49
  "velox",