Repository navigation
Commit 96e1526
committed
fix(zod): treat @uuid without a version as any UUID version
`addStringValidation` in packages/zod/src/utils.ts mapped the `@uuid`
attribute with `if (version === 7) uuidv7() else uuidv4()`, so the
no-version form fell into the v4 branch and rejected every other UUID
version. stdlib.zmodel declares the version argument as optional and
documents the attribute as "Validates a string field value is a valid
UUID", and the `isUuid()` branch in the same file already passes an
undefined version to `z.uuid()`, which accepts any version.
Writing a v7 or v1 UUID into a `String @uuid` field therefore failed with
`Validation error: Invalid UUID`. v7 is the shape ZenStack's own `uuid(7)`
generator produces, at
packages/orm/src/client/crud/operations/base.ts:1119.
Only the no-version branch changes, to `result.uuid()`. `@uuid(4)` and
`@uuid(7)` stay pinned, and the `@uuid` check in
attribute-application-validator.ts already rejects any other version
literal.1 parent a4a25c4 commit 96e1526
2 files changed
Lines changed: 21 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | | - | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
86 | 88 | | |
87 | 89 | | |
88 | | - | |
| 90 | + | |
89 | 91 | | |
90 | 92 | | |
91 | 93 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
120 | 121 | | |
121 | 122 | | |
122 | 123 | | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
123 | 127 | | |
124 | 128 | | |
125 | 129 | | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
126 | 135 | | |
127 | 136 | | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
128 | 145 | | |
129 | 146 | | |
130 | 147 | | |
| |||
0 commit comments