Thanks to my clever nephews for finding this degenerate case that I
had missed when coding this up originally.
}
add_prompt(items, prompt_string) {
- if (items > MAX_PROMPT_ITEMS)
+ if (items > MAX_PROMPT_ITEMS) {
return {
valid: false,
message: `Maximum number of items is ${MAX_PROMPT_ITEMS}`
};
+ }
+
+ if (items < 1) {
+ return {
+ valid: false,
+ message: "Category must require at least one item"
+ };
+ }
const prompt = new Prompt(this.next_prompt_id, items, prompt_string);
this.next_prompt_id++;