Commit 3509d7e
make v.nullable more explicit about needing a required value (#43112)
currently `v.nullable(v.optional(v.string()))` will "work" but if you try to assign it to a validator, you'll get a difficult to parse error like below. Instead let's have the error at the v.nullable callsite, since it needs a required value right now.
```
Type 'VUnion<{ author: string; body: string; _creationTime: number; _id: Id<"messages">; } | null | undefined, [VObject<{ author: string; body: string; _creationTime: number; _id: Id<"messages">; } | undefined, { ...; }, "optional", "_creationTime" | ... 2 more ... | "_id">, VNull<...>], "required", "_creationTime" | ... ...' is not assignable to type 'void | PropertyValidators | Validator<any, "required", any> | undefined'.
Type 'VUnion<{ author: string; body: string; _creationTime: number; _id: Id<"messages">; } | null | undefined, [VObject<{ author: string; body: string; _creationTime: number; _id: Id<"messages">; } | undefined, { ...; }, "optional", "_creationTime" | ... 2 more ... | "_id">, VNull<...>], "required", "_creationTime" | ... ...' is not assignable to type 'VUnion<any, Validator<any, "required", any>[], "required", any>'.
Type '[VObject<{ author: string; body: string; _creationTime: number; _id: Id<"messages">; } | undefined, { author: VString<string, "required">; body: VString<string, "required">; _id: VId<...>; _creationTime: VFloat64<...>; }, "optional", "_creationTime" | ... 2 more ... | "_id">, VNull<...>]' is not assignable to type 'Validator<any, "required", any>[]'.
Type 'VNull<null, "required"> | VObject<{ author: string; body: string; _creationTime: number; _id: Id<"messages">; } | undefined, { author: VString<string, "required">; body: VString<...>; _id: VId<...>; _creationTime: VFloat64<...>; }, "optional", "_creationTime" | ... 2 more ... | "_id">' is not assignable to type 'Validator<any, "required", any>'.
Type 'VObject<{ author: string; body: string; _creationTime: number; _id: Id<"messages">; } | undefined, { author: VString<string, "required">; body: VString<string, "required">; _id: VId<...>; _creationTime: VFloat64<...>; }, "optional", "_creationTime" | ... 2 more ... | "_id">' is not assignable to type 'Validator<any, "required", any>'.
Type 'VObject<{ author: string; body: string; _creationTime: number; _id: Id<"messages">; } | undefined, { author: VString<string, "required">; body: VString<string, "required">; _id: VId<...>; _creationTime: VFloat64<...>; }, "optional", "_creationTime" | ... 2 more ... | "_id">' is not assignable to type 'VObject<any, Record<string, Validator<any, OptionalProperty, any>>, "required", any>'.
Type '"optional"' is not assignable to type '"required"'.ts(2322)
```
GitOrigin-RevId: 74c4906c0c0495000349ccc6e84814993a9494f31 parent 098f0a5 commit 3509d7e
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
226 | 226 | | |
227 | 227 | | |
228 | 228 | | |
229 | | - | |
| 229 | + | |
230 | 230 | | |
231 | 231 | | |
232 | 232 | | |
| |||
0 commit comments