Input validation using bit flags