]> git.cworth.org Git - lmno.games/blobdiff - empathy/empathy.jsx
Reject a category with a number of items of 0
[lmno.games] / empathy / empathy.jsx
index 0593b049a30e6a0811f355f1a044fd1e2cb84853..6acf526c3516da99cdf72f282c65ff5ad894a8be 100644 (file)
@@ -283,7 +283,7 @@ class CategoryRequest extends React.PureComponent {
     const match = category.match(/[0-9]+/);
     if (match) {
       const num_items = parseInt(match[0], 10);
-      if (num_items <= MAX_PROMPT_ITEMS)
+      if (num_items > 0 && num_items <= MAX_PROMPT_ITEMS)
         category_input.setCustomValidity("");
     }
   }
@@ -311,6 +311,12 @@ class CategoryRequest extends React.PureComponent {
       return;
     }
 
+    if (num_items < 1) {
+      category_input.setCustomValidity("Category must require at least one item.");
+      form.reportValidity();
+      return;
+    }
+
     const response = await fetch_post_json("prompts", {
       items: num_items,
       prompt: category