The time-slot demo matched a full input, not just a valid substring. Here a storage clerk enters labels such as B-07; allow surrounding spaces and lowercase letters, but reject a nonexistent row or bay.
A valid normalized label has row A, B, or C, a hyphen, then a two-digit bay from 01 through 12. This is a format check, not a lookup of shelves currently in use.
An anchored pattern for an unrelated ticket code validates the whole string:
const ticket = /^[A-Z]{2}-[0-9]{2}$/;
console.log(ticket.test("AB-07")); // true
console.log(ticket.test("xAB-07")); // false
normalizeShelfLabel(input) by trimming and uppercasing input.isValidShelfLabel(input) by testing the normalized whole string: rows A–C and bays 01–12 only." b-07 " and "D-07": B-07: true | D-07: false.You can now turn loosely entered text into validated labels. Take the section quiz before moving on to functional programming.
First trim the input and convert it to uppercase.
Use ^ and $ so extra characters cannot pass; (0[1-9]|1[0-2]) covers 01 through 12.