Skip to content

Commit b0e1375

Browse files
committed
feat: Default to more permissive for additional columns in TSV
1 parent 43be015 commit b0e1375

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/schema/tables.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,11 @@ export function evalAdditionalColumns(
239239
if (context.extension !== '.tsv') return
240240
const headers = Object.keys(context?.columns)
241241
if (rule.columns) {
242+
if (!rule.additional_columns || rule.additional_columns === 'n/a' ) {
243+
// Old schemas might be missing the field, so be permissive.
244+
// New schemas indicate it is not applicable with 'n/a'.
245+
return
246+
}
242247
const ruleHeadersNames = Object.keys(rule.columns).map(
243248
// @ts-expect-error
244249
(x) => schema.objects.columns[x].name,
@@ -250,11 +255,11 @@ export function evalAdditionalColumns(
250255
if (rule.additional_columns?.startsWith('allowed')) {
251256
extraCols = extraCols.filter((header) => !(header in context.sidecar))
252257
}
253-
const code = rule.additional_columns === 'allowed'
254-
? 'TSV_ADDITIONAL_COLUMNS_UNDEFINED'
258+
const code = rule.additional_columns === 'not_allowed'
259+
? 'TSV_ADDITIONAL_COLUMNS_NOT_ALLOWED'
255260
: rule.additional_columns === 'allowed_if_defined'
256261
? 'TSV_ADDITIONAL_COLUMNS_MUST_DEFINE'
257-
: 'TSV_ADDITIONAL_COLUMNS_NOT_ALLOWED'
262+
: 'TSV_ADDITIONAL_COLUMNS_UNDEFINED'
258263
const issue = {
259264
code,
260265
location: context.path,

0 commit comments

Comments
 (0)