Fix problem checking before sending to server
[vchess.git] / client / src / data / problemCheck.js
index 3b9ccb4..b9fe04d 100644 (file)
@@ -1,9 +1,12 @@
-export function checkProblem(p)
-{
+export function checkProblem(p) {
   const vid = parseInt(p.vid);
-  if (isNaN(vid) || vid <= 0)
-    return "Please select a variant";
+  if (isNaN(vid) || vid <= 0) return "Please select a variant";
 
-  if (!V.IsGoodFen(p.fen))
-    return "Bad FEN string";
+  if (!V.IsGoodFen(p.fen)) return "Errors in FEN";
+
+  if (p.instruction.trim().length == 0) return "Empty instructions";
+
+  if (p.solution.trim().length == 0) return "Empty solution";
+
+  return "";
 }