@kaapi/validator-valibot 0.0.26 → 0.0.28

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 (2) hide show
  1. package/README.md +21 -21
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -47,12 +47,12 @@ await app.extend(validatorValibot); // register the plugin
47
47
  ### 📐 Define a Schema
48
48
 
49
49
  ```ts
50
- import { object, string } from 'valibot'
50
+ import * as v from 'valibot'
51
51
  import { ValidatorValibotSchema } from '@kaapi/validator-valibot'
52
52
 
53
53
  const routeSchema: ValidatorValibotSchema = {
54
- payload: object({
55
- name: string()
54
+ payload: v.object({
55
+ name: v.string()
56
56
  })
57
57
  }
58
58
  ```
@@ -140,15 +140,15 @@ This sets `abortEarly` to `true` for all Valibot-validated routes, and logs vali
140
140
 
141
141
  ```ts
142
142
  app.base().valibot({
143
- query: object({
144
- name: optional(pipe(string(), trim(), nonEmpty(), maxLength(10), description('Optional name to personalize the greeting response')), 'World'),
145
- age: optional(
146
- pipe(
147
- string(),
148
- transform((input) => typeof input === 'string' ? Number(input) : input),
149
- number(),
150
- integer(),
151
- minValue(1)
143
+ query: v.object({
144
+ name: v.optional(v.pipe(v.string(), v.trim(), v.nonEmpty(), v.maxLength(10), v.description('Optional name to personalize the greeting response')), 'World'),
145
+ age: v.optional(
146
+ v.pipe(
147
+ v.string(),
148
+ v.transform((input) => typeof input === 'string' ? Number(input) : input),
149
+ v.number(),
150
+ v.integer(),
151
+ v.minValue(1)
152
152
  )
153
153
  )
154
154
  }),
@@ -179,18 +179,18 @@ Multipart file uploads with Valibot validation is supported. Here's how to valid
179
179
 
180
180
  ```ts
181
181
  app.base().valibot({
182
- payload: object({
183
- file: pipe(
184
- looseObject({
185
- _data: instance(Buffer),
186
- hapi: looseObject({
187
- filename: string(),
188
- headers: looseObject({
189
- 'content-type': picklist(['image/jpeg', 'image/jpg', 'image/png'] as const)
182
+ payload: v.object({
183
+ file: v.pipe(
184
+ v.looseObject({
185
+ _data: v.instance(Buffer),
186
+ hapi: v.looseObject({
187
+ filename: v.string(),
188
+ headers: v.looseObject({
189
+ 'content-type': v.picklist(['image/jpeg', 'image/jpg', 'image/png'] as const)
190
190
  })
191
191
  })
192
192
  }),
193
- description('The image to upload')
193
+ v.description('The image to upload')
194
194
  )
195
195
  })
196
196
  }).route({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaapi/validator-valibot",
3
- "version": "0.0.26",
3
+ "version": "0.0.28",
4
4
  "private": false,
5
5
  "description": "Valibot-powered request validation and documentation plugin for Kaapi.",
6
6
  "main": "lib/index.js",
@@ -29,7 +29,7 @@
29
29
  "@novice1/api-doc-generator": "^1.2.0",
30
30
  "@valibot/to-json-schema": "^1.3.0",
31
31
  "tslib": "^2.8.1",
32
- "@kaapi/kaapi": "^0.0.26"
32
+ "@kaapi/kaapi": "^0.0.28"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "valibot": "^1.1.0"