Skip to content

Are schemas broken? #706

Open
Open
@mjgs

Description

@mjgs

I have been having an issue where date strings are being converted to date objects but I want to keep them as strings.

The load function works without a schema specified. I tried using the various schemas hoping I could get just plain old strings but specifying any schema results in the error:

TypeError: Cannot read properties of undefined (reading 'length')
[46](https://github.com/mjgs/convert-data-using-scripts/actions/runs/4892166937/jobs/8733596341#step:17:47)
    at composeNode (/home/runner/work/convert-data-using-scripts/convert-data-using-scripts/main/node_modules/js-yaml/lib/loader.js:1492:60)

I specified the schema like so:

const jsYaml = require('js-yaml');
const { fm, content } = extractFrontmatter(contents);
const extractedData = jsYaml.load(fm, {
  schema: 'FAILSAFE_SCHEMA'
});

Are schemas broken? Is there another way to prevent date strings being converted into date objects?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions