# Template field checker v1

A dependency-free JavaScript module for checking a text template against one
pasted tab-separated header row. Works offline in a modern browser or Node.js
18+. It makes no network requests, reads no files and has no telemetry.
This is the same implementation as the bulldo.gs browser template checker.

Save `template-checker.mjs` beside your script. For example, save this as
`check.mjs` and run `node check.mjs`:

```js
import { checkTemplate } from './template-checker.mjs';
const result = checkTemplate('Hello {{name}}, due {{date}}.', 'name\tdate');
console.log(result);
// { lines: ['Field "name": column A', 'Field "date": column B'], checked: 2, issues: 0 }
```

`checkTemplate(template, headers)` returns `{lines, checked, issues}`. `checked`
is the number of unique placeholder names, not document rows. `issues` counts
missing fields, blank columns, duplicate header names and unused header names.
A duplicate unused header may cause two issues. Repeated placeholders are fine.
Column references use spreadsheet letters (A through SF for 500 columns).
Unused columns may be intentional: review the output rather than deleting them.

Names are trimmed and case-sensitive. Template placeholders use `{{field}}`;
empty, unmatched or nested delimiters and braces/line breaks inside names throw.
Header input is one tab-separated row; a single terminal newline is accepted.
Limits: 100,000 characters per input, 500 distinct fields and 500 header columns.
Missing placeholders, multiple header rows and oversized input throw errors.
The module does not replace text, validate scripts, read Google Docs or Sheets,
check row values, connect to an account or generate/send documents.

Source build in the repository: `node scripts/build-template-checker.mjs`.
Check byte parity: `node scripts/build-template-checker.mjs --check`.
Local execution is not observable by bulldo.gs; a download is not evidence of use.

## License

MIT License

Copyright (c) 2026 QuasiLife

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

