# Required-fields check v1

Preview empty required cells in a literal tab-separated table. Save
`required-fields-check.mjs` beside this file and save this fictional example
as `required-fields-example.mjs`:

```js
import assert from 'node:assert/strict';
import { checkRequiredFields } from './required-fields-check.mjs';

const table = 'id\tname\tstatus\n001\tAlex\tready\n002\t \t\n\t\t';
const result = checkRequiredFields(table, '2,3');
console.log(result.lines.join('\n'));
assert.deepEqual(result, {
  checked: 3,
  issues: 4,
  lines: [
    'Row 3, column 2: missing required value.',
    'Row 3, column 3: missing required value.',
    'Row 4, column 2: missing required value.',
    'Row 4, column 3: missing required value.',
  ],
});
```

Run `node required-fields-example.mjs`. The function returns
`{ checked, issues, lines }`; invalid input throws an error. `checked` counts
data rows, while `issues` counts missing cells. The header row is required for
the table shape but is not checked for missing values. Blank and duplicate
headers are allowed.

Supply required columns manually as comma-separated **1-based positions**,
such as `2,3`. The checker does not infer fields from header names. Numbers
must be positive whole numbers without leading zeros, within the table width,
and unique. It checks only selected columns. A cell is missing when its value
is empty or whitespace-only under JavaScript `trim()`; values such as `0` and
formula-like text are present, without being validated or evaluated.

Tabs and newlines always separate cells: CSV quoting and multiline cells are
unsupported. CRLF and lone CR become LF. One final newline is ignored; other
blank rows remain and may produce findings. Every row, including the header,
must have the same number of columns. A ragged row throws an error rather than
being silently padded or truncated. Limits: 100,000 table characters, 2,000
selection characters, 500 rows including the header, and 500 columns.
Findings use original row and numeric column positions without copying cell
contents. This is a missing-value preview, not a business-validity check.
Review findings in the original source. This module has no network calls,
spreadsheet access, data writes or automatic corrections.

Generated from the exact browser core in `site/lib/required-fields.ts`.
`node scripts/build-required-fields-check.mjs --check` checks byte parity.
No install or dependencies are needed for this local JavaScript example.

## 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.
