Skip to content

Validate first ​

Always run check before render. It validates template + data without rendering anything.

Basic usage ​

bash
lakreet-swarm check --template template.ectemplate --data data.csv

Success output ​

OK
  template:  template.ectemplate
  controls:  2 (Source Text, Opacity)
  data:      data.csv
  rows:      5 valid

Exit code: 0

Error output ​

Found 2 problem(s) in data.csv:
- Line 3, column "Opacity": "abc" is not a number.
- Line 5, column "Source Text": column "Source Text" is required.

Exit code: 3 (DATA_INVALID)

A column that maps to a media control stops check before any problem list:

Column "Logo" maps to a media control; media replacement is not supported yet.
  Hint: Use text, number or checkbox controls for now, or remove the column.

Exit code: 3 (E_MEDIA_UNSUPPORTED)

What gets validated ​

CheckExample error
Column matches controlColumn "Foo" is not a control of the template
Slider = number"abc" is not a number
Checkbox = boolean"yes" is not a boolean (accepts true/false/yes/no/1/0/ya/tidak)
Media control presentmedia replacement is not supported yet
Required columns presentcolumn "Source Text" is required
Row column count matches headerexpected 2 columns, found 3

Exit codes for scripting ​

CodeConstantMeaning
0OKAll valid
3DATA_INVALIDValidation failed
bash
lakreet-swarm check --template t.ectemplate --data d.csv
if [ $? -eq 3 ]; then
  echo "Fix data before rendering"
  exit 1
fi

With column mapping ​

Mapping in lakreet.config.json is applied during check:

bash
lakreet-swarm check --template t.ectemplate --data d.csv --config lakreet.config.json

Dry-run render ​

Alternative: render --dry-run does the same validation but exits 0 on success:

bash
lakreet-swarm render --template t.ectemplate --data d.csv --dry-run
# 5 row(s) valid. Dry run: nothing rendered.

In CI pipelines ​

yaml
# .github/workflows/ci.yml
- name: Validate data
  run: lakreet-swarm check --template ${{ env.TEMPLATE }} --data ${{ env.DATA }}

Fails fast, no render cost, clear error messages.

Next steps ​