@veloxts/validation 0.6.92 → 0.6.94

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 +16 -0
  2. package/GUIDE.md +36 -0
  3. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @veloxts/validation
2
2
 
3
+ ## 0.6.94
4
+
5
+ ### Patch Changes
6
+
7
+ - feat(client): add tRPC router type support for ClientFromRouter and VeloxHooks
8
+ - Updated dependencies
9
+ - @veloxts/core@0.6.94
10
+
11
+ ## 0.6.93
12
+
13
+ ### Patch Changes
14
+
15
+ - feat(router): add Resource API with phantom types for context-dependent outputs
16
+ - Updated dependencies
17
+ - @veloxts/core@0.6.93
18
+
3
19
  ## 0.6.92
4
20
 
5
21
  ### Patch Changes
package/GUIDE.md CHANGED
@@ -183,6 +183,42 @@ export const userProcedures = procedures('users', {
183
183
  });
184
184
  ```
185
185
 
186
+ ## Resource API with Zod Schemas
187
+
188
+ For context-dependent outputs, use `resourceSchema()` with Zod field schemas:
189
+
190
+ ```typescript
191
+ import { resourceSchema, resource } from '@veloxts/router';
192
+ import { z } from '@veloxts/validation';
193
+
194
+ // Define field visibility with Zod schemas
195
+ const UserSchema = resourceSchema()
196
+ .public('id', z.string().uuid())
197
+ .public('name', z.string())
198
+ .authenticated('email', z.string().email())
199
+ .admin('internalNotes', z.string().nullable())
200
+ .build();
201
+
202
+ // Returns different fields based on access level
203
+ const publicUser = resource(user, UserSchema).forAnonymous();
204
+ // Type: { id: string; name: string }
205
+
206
+ const authUser = resource(user, UserSchema).forAuthenticated();
207
+ // Type: { id: string; name: string; email: string }
208
+
209
+ const adminUser = resource(user, UserSchema).forAdmin();
210
+ // Type: { id: string; name: string; email: string; internalNotes: string | null }
211
+ ```
212
+
213
+ ### When to Use Each Approach
214
+
215
+ | Scenario | Approach |
216
+ |----------|----------|
217
+ | Same output for all users | `.output(zodSchema)` |
218
+ | Different fields per role | `resourceSchema()` + `resource()` |
219
+ | Input validation | `.input(zodSchema)` |
220
+ | Complex transforms | `.output()` with Zod transforms |
221
+
186
222
  ## Error Handling
187
223
 
188
224
  Validation errors include field-level details:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veloxts/validation",
3
- "version": "0.6.92",
3
+ "version": "0.6.94",
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.92"
26
+ "@veloxts/core": "0.6.94"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@vitest/coverage-v8": "4.0.18",