Skip to content

Validation ​

lakreet-swarm validates every row before rendering a single frame. This is a deliberate design choice.

Why validate first? ​

BenefitExplanation
Fail fastCatch all errors in 1 second vs discovering at row 500 after 2 hours
Complete pictureSee all problems at once, fix in one edit
No partial wasteDon't burn CPU/GPU on rows that will fail
CI friendlycheck exits with code 3, no render cost

Validation model ​

Data file -> Parse -> Map columns -> Coerce types -> Check media -> All errors or valid rows

Every step runs for all rows before any render.

Error reporting ​

Errors include exact location:

Found 3 problem(s) in data.csv:
- Line 5, column "Opacity": "abc" is not a number.
- Line 8, column "Source Text": column "Source Text" is required.
- Line 12, column "Logo": file not found: /assets/missing.png
  • Line numbers: 1-based, header = line 1 (CSV) or item number (JSON/JSONL)
  • Column names: Original header (before mapping) or JSON key
  • All at once: No "fix one, re-run, find next" loop

Type coercion ​

Input typeControl typeCoercionValidation
stringtextpass throughalways ok
numbersliderpass throughfinite check
stringsliderparse floatNaN/Infinity rejected
booleancheckboxpass throughexact match
stringcheckboxparse truthy/falsyknown words only

Unknown types -> fallback to text (no hard failure).

Media validation ​

Media columns validated as file paths:

  • Relative paths resolved against data file folder or --media-dir
  • Existence checked
  • Warnings for suspicious paths (outside mediaDir)

Warnings vs errors ​

LevelExampleBehavior
ErrorType mismatch, missing fileBlocks render, exit code 3
WarningUnknown manifest version, deprecated columnLogged to stderr, render proceeds

Programmatic API ​

javascript
import { readRows } from "lakreet-swarm/data";

const { rows, problems, warnings } = readRows("data.csv", controls, options);

if (problems.length > 0) {
  console.error(problems.join("\n"));
  process.exit(3);
}

Next steps ​

Independent project. Not affiliated with the ArtCraft team or the EffectCraft project.