From b30585187480a270826767eaf97e1acc66126072 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Mon, 22 Jan 2024 10:31:58 -0400 Subject: data, yaml: mark ignored fields on `fields` --- src/data/yaml.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/data/yaml.js') diff --git a/src/data/yaml.js b/src/data/yaml.js index 19f5629..fe8bfdc 100644 --- a/src/data/yaml.js +++ b/src/data/yaml.js @@ -80,14 +80,12 @@ function makeProcessDocument(thingConstructor, { // YAML into some other format before providing setting it on the Thing // instance. // - fields: fieldSpecs = {}, - - // Completely ignored fields. These won't throw an unknown field error if - // they're present in a document, but they won't be used for Thing property - // generation, either. Useful for stuff that's present in data files but not - // yet implemented as part of a Thing's data model! + // If a field entry has `ignore: true`, it will be completely skipped by the + // YAML parser - it won't be validated, read, or loaded into data objects. + // This is mainly useful for fields that are purely annotational or are + // currently placeholders. // - ignoredFields = [], + fields: fieldSpecs = {}, // List of fields which are invalid when coexisting in a document. // Data objects are generally allowing with regards to what properties go @@ -120,6 +118,11 @@ function makeProcessDocument(thingConstructor, { const knownFields = Object.keys(fieldSpecs); + const ignoredFields = + Object.entries(fieldSpecs) + .filter(([, {ignore}]) => ignore) + .map(([field]) => field); + const propertyToField = withEntries(fieldSpecs, entries => entries .map(([field, {property}]) => [property, field])); -- cgit 1.3.0-6-gf8a5