Input validation
Check that the requested seat is between one and the last seat. Returning false lets the booking screen ask for a new number.
Simple example
Is zero in the range one to three?
Start0 · 1–3
Resultfalse
const std = @import("std");
pub fn main() !void {
std.debug.print("{any}\n", .{0 >= 1 and 0 <= 3});
}
false
Advertisements
Everyday examples
A school bus has 30 seats. Can a learner reserve seat 30?
StartSeat 30 · 30 seats
Resulttrue
const std = @import("std");
pub fn main() !void {
std.debug.print("{any}\n", .{30 >= 1 and 30 <= 30});
}
true