@@ -35,20 +35,28 @@ const roomSchemaHelper = z
3535 . toUpperCase ( )
3636 . trim ( )
3737 . transform ( normalizeRoomString )
38- . refine ( ( val ) => Object . hasOwn ( rooms , val ) || val === "" ) ;
38+ . refine ( ( val ) => Object . hasOwn ( rooms , val ) ) ;
3939
4040/**
4141 * Represents the custom schema for a room.
4242 *
4343 * This schema is used to validate if a value is a valid room.
4444 * A valid room, well, exists in the list of rooms.
45- * In addition, this allows an empty string to pass, so that that validation can be caught better.
4645 */
47- const roomSchema = z . custom < keyof typeof rooms | "" > (
46+ const roomSchema = z . custom < keyof typeof rooms > (
4847 ( val ) => roomSchemaHelper . safeParse ( val ) . success ,
4948 ( val ) => ( { message : `${ val } is not a room` } ) ,
5049) ;
5150
51+ /**
52+ * Represents the custom schema for a room.
53+ *
54+ * This schema is used to validate if a value is a valid room.
55+ * A valid room, well, exists in the list of rooms.
56+ * In addition, this allows an empty string to pass, so that that validation can be caught better.
57+ */
58+ const roomSchemaUnion = z . union ( [ roomSchema , z . literal ( "" ) ] ) ;
59+
5260/**
5361 * Represents the schema for profiles data.
5462 */
@@ -97,7 +105,7 @@ const stairListSchema = z.record(
97105
98106export {
99107 profilesListSchema ,
100- roomSchema ,
108+ roomSchemaUnion as roomSchema ,
101109 type Level ,
102110 type Lvl ,
103111 type ProfilesList ,
0 commit comments