Skip to content

List type not validating as expected #87

Closed

Description

@seancdavis

Given the following config:

const Tag = defineDocumentType(() => ({
  name: 'Tag',
  filePathPattern: 'tags/*.md',
  bodyType: 'none',
  fields: {
    title: { type: 'string', required: true },
  },
}))

const Doc = defineDocumentType(() => ({
  name: 'Doc',
  filePathPattern: '**/*.mdx',
  bodyType: 'mdx',
  fields: {
    title: { type: 'string', required: true },
    tags: { type: 'list', of: Tag },
  },
}))

export default makeSource({
  contentDirPath: 'content',
  documentTypes: [Doc, Tag],
})

The tags field on Doc type is a list of references. It should validate when a value doesn't match a valid (relative) path to a file matching the correct type.

Today if I do this in my doc's frontmatter:

---
title: Hello World
tags:
  - Hello
  - World
---

I see a warning:

└── 2 documents contain field data which didn't match the structure defined in the document type definition
     
     • "index.mdx" of type "Doc" has the following incompatible fields:
       • tags: undefined 
     • "sub/b.mdx" of type "Doc" has the following incompatible fields:
       • tags: undefined

But it still generates the document with the list like so:

{
  "title": "Hello World",
  "tags": [
    "Hello",
    "World"
  ]
}

Activity

  1. added
    bug
    on Jan 5, 2022
  2. stale commented on Mar 6, 2022

    @stale

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

  3. added this to the 0.2.8 milestone on Sep 6, 2022
  4. schickling commented on Sep 9, 2022

    @schickling
    Collaborator

    This should be addressed with the 0.2.8 release. 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions