@lankajs/typebox 1.0.0 → 1.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lankajs/typebox",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "module: A bridge for the one library in the family with no Standard Schema, and a compiled checker it caches.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
"skills"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"lanka": "^
|
|
29
|
+
"lanka": "^2.0.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@lankajs/tool-testing": "^
|
|
32
|
+
"@lankajs/tool-testing": "^2.0.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"@sinclair/typebox": "^0.34.52"
|
|
@@ -5,7 +5,7 @@ license: MIT
|
|
|
5
5
|
metadata:
|
|
6
6
|
author: lankajs
|
|
7
7
|
package: @lankajs/typebox
|
|
8
|
-
version: "1.0.
|
|
8
|
+
version: "1.0.1"
|
|
9
9
|
---
|
|
10
10
|
|
|
11
11
|
# @lankajs/typebox
|
|
@@ -107,12 +107,12 @@ that throws is a refused body, not a crash.
|
|
|
107
107
|
|
|
108
108
|
## Symptom → cause
|
|
109
109
|
|
|
110
|
-
| What you see
|
|
111
|
-
|
|
|
112
|
-
| validation slower than expected
|
|
113
|
-
| "Unknown format" in a message
|
|
114
|
-
| a path like `/a/b` reaching your form
|
|
115
|
-
| "invalid response" with no idea which
|
|
110
|
+
| What you see | What it is |
|
|
111
|
+
| ------------------------------------- | ----------------------------------------------- |
|
|
112
|
+
| validation slower than expected | a schema rebuilt per render — nothing is cached |
|
|
113
|
+
| "Unknown format" in a message | a `format` keyword nothing registered |
|
|
114
|
+
| a path like `/a/b` reaching your form | not from here — this package returns segments |
|
|
115
|
+
| "invalid response" with no idea which | a label that does not identify the call |
|
|
116
116
|
|
|
117
117
|
## More
|
|
118
118
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<!-- Generated from modules/validators/typebox/GUIDE.md by scripts/skills.mjs. Edit the guide. -->
|
|
2
2
|
|
|
3
|
-
> **`@lankajs/typebox@1.0.
|
|
3
|
+
> **`@lankajs/typebox@1.0.1`** — this document describes that version.
|
|
4
4
|
>
|
|
5
|
-
> Install: `npm install @lankajs/typebox @sinclair/typebox
|
|
5
|
+
> Install: `npm install @lankajs/typebox @sinclair/typebox zustand` (the peers are not optional; only npm adds a missing one for you).
|
|
6
6
|
>
|
|
7
7
|
> Complete code, compiled and run in CI: [modules/validators/typebox/_playground/playground.test.ts](https://github.com/lankajs/lanka/blob/main/modules/validators/typebox/_playground/playground.test.ts)
|
|
8
8
|
|
|
@@ -30,9 +30,13 @@ The moment your schemas are TypeBox. Core's validator cannot be handed one.
|
|
|
30
30
|
## Install
|
|
31
31
|
|
|
32
32
|
```bash
|
|
33
|
-
npm install @lankajs/typebox @sinclair/typebox
|
|
33
|
+
npm install @lankajs/typebox @sinclair/typebox zustand
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
+
> [!IMPORTANT]
|
|
37
|
+
> `zustand` is `lanka`'s own peer: npm adds a missing peer for you and pnpm
|
|
38
|
+
> does not, so the line names it.
|
|
39
|
+
|
|
36
40
|
## Do I need it?
|
|
37
41
|
|
|
38
42
|
Yes. TypeBox publishes no `~standard` at all — not asynchronously as yup does,
|
|
@@ -119,7 +123,10 @@ A mapping is a schema, not an adapter layer. In TypeBox it is
|
|
|
119
123
|
|
|
120
124
|
```ts
|
|
121
125
|
const todoFromApi = Type.Transform(
|
|
122
|
-
Type.Object({
|
|
126
|
+
Type.Object({
|
|
127
|
+
todo_id: Type.Number(),
|
|
128
|
+
is_done: Type.Union([Type.Literal(0), Type.Literal(1)]),
|
|
129
|
+
}),
|
|
123
130
|
)
|
|
124
131
|
.Decode((wire) => ({ id: wire.todo_id, done: wire.is_done === 1 }))
|
|
125
132
|
.Encode((domain) => ({ todo_id: domain.id, is_done: domain.done ? 1 : 0 }));
|