Skip to content
This repository has been archived by the owner on Jul 10, 2024. It is now read-only.

Commit

Permalink
chore: update normalization of rooms
Browse files Browse the repository at this point in the history
  • Loading branch information
lishaduck committed Nov 20, 2023
1 parent 34f1c1a commit 76a5208
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/data/data-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@ type Room = keyof Rooms;

const levelSchema = z.array(z.array(z.number()));

function normalizeRoomString(room: string): string {
return room
.normalize()
.replaceAll("-", "")
.replaceAll("_", "")
.replaceAll("#", "")
.replaceAll("/", "");
}

const roomSchema = z
.string()
.toUpperCase()
.trim()
.transform((val) =>
val
.normalize()
.replaceAll("-", "")
.replaceAll("_", "")
.replaceAll("#", "")
.replaceAll("/", ""),
)
.transform(normalizeRoomString)
.refine((val) => Object.hasOwn(rooms, val))
.transform((val) => val as Room);

Expand Down

0 comments on commit 76a5208

Please sign in to comment.