Skip to content

Commit 8b6b854

Browse files
ianmacartneyConvex, Inc.
authored andcommitted
Ian/v.nullable (#42913)
- extra sugar GitOrigin-RevId: fa2580bfde61b27d880d025e1e3c2919257deef4
1 parent 74f68e7 commit 8b6b854

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/values/validator.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,13 @@ export const v = {
222222
optional: <T extends GenericValidator>(value: T) => {
223223
return value.asOptional() as VOptional<T>;
224224
},
225+
226+
/**
227+
* Allows specifying a value or null.
228+
*/
229+
nullable: <T extends GenericValidator>(value: T) => {
230+
return v.union(value, v.null());
231+
},
225232
};
226233

227234
/**

0 commit comments

Comments
 (0)