diff options
Diffstat (limited to 'src/data/yaml.js')
-rw-r--r-- | src/data/yaml.js | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/data/yaml.js b/src/data/yaml.js index 19f56292..fe8bfdc0 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])); |