Generate SSD JSONL validation from typed Jerboa

ober

06531a0b88374e9e6931afc9ba40b79bdcbad942

diff --git a/templates/ssd-review.ss b/templates/ssd-review.ss
index bf3bd7d..6974b8d 100644
--- a/templates/ssd-review.ss
+++ b/templates/ssd-review.ss
@@ -4749,6 +4749,7 @@
                 shouldIncludeSsdPdfDocument
                 trimmedNonBlankLines trimmedNonBlankPathParts
                 mergeJsonLinesTextFromLocalAndRemote
+                validateImportedJsonLinesText
                 ensureTruthStoreDirectories
                 sourceBaseName canonicalSourceName isUsefulGuessLabel isErrorStatus
                 formatActivityDuration groupDisplayLabel appendModeStatus
@@ -5829,6 +5830,24 @@
                 (trimmedNonBlankLines remoteText)
                 limit)
               (mergedJsonLinesTextFromMutableSet lines))))
+        (def (validateImportedJsonLinesText
+               (text : String)
+               (limit : Int32)) : Unit
+          (let ((items (trimmedNonBlankLines text)))
+            (begin
+              (for/fold ((lines (int32 0)))
+                        ((i (in-range (int32 0) (list-size items))))
+                (let ((next (+ lines (int32 1))))
+                  (begin
+                    (if (jsonLineCountExceeded next limit)
+                        (throw
+                          (illegalStateException
+                            "JSONL line-count limit exceeded")
+                          Unit)
+                        (begin))
+                    (jsonObjectFromText (list-ref items i))
+                    next)))
+              (begin))))
         (def (sourceBaseName (value : String)) : String
           (string-lowercase
             (string-replace-regex
@@ -11899,12 +11918,7 @@
        ""
        "    private fun validateImportedText(name: String, text: String) {"
        "        if (jsonLinesFileName(name)) {"
-       "            var lines = 0"
-       "            trimmedNonBlankLines(text).forEach { line ->"
-       "                lines += 1"
-       "                if (jsonLineCountExceeded(lines, MAX_JSONL_LINES)) throw IllegalStateException(\"JSONL line-count limit exceeded\")"
-       "                jsonObjectFromText(line)"
-       "            }"
+       "            validateImportedJsonLinesText(text, MAX_JSONL_LINES)"
        "        } else {"
        "            jsonObjectFromText(text)"
        "        }"