Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typeError: validations.map is not a function: linkContentType can be a string or a string[] #148

Closed
parkerhutchinson opened this issue Nov 2, 2021 · 3 comments · Fixed by #282
Labels

Comments

@parkerhutchinson
Copy link

The validations are failing for me because it thinks that linkContentType can only be an array of string values. Wrong assumption linkContentType can be a string or an array of strings

LinkContentType: ['entryRef', 'entryRefTwo']
or
LinkContentType: 'entryRef'

This may go against the official docs but it is allowed and is valid migration using contentfuls DSL.

@parkerhutchinson
Copy link
Author

parkerhutchinson commented Nov 2, 2021

here is the migration that allows this to happen:

page.createField('refField', {
    name: 'Ref Field,
    type: 'Array',
    required: true,
    items: {
      type: "Link",
      linkType: "Entry",
      validations: [{
        linkContentType: 'contentTypeId'
      }]
    }
  });

this will show as a string in the JSON output on the content type and be a valid link type.

I can fix this on my end of course by doing this:

page.createField('refField', {
    name: 'Ref Field,
    type: 'Array',
    required: true,
    items: {
      type: "Link",
      linkType: "Entry",
      validations: [{
        linkContentType: ['contentTypeId']
      }]
    }
  });

This will fix the issue and return a string[] as your tool expects. But this would confuse the crap out of most people. Should support both string and string[] for linkContentType

@marcolink
Copy link
Collaborator

Hi @parkerhutchinson,

That sounds like a reasonable change! I'm currently pretty busy - would it be possible for you to create a PR for that?

@github-actions
Copy link

🎉 This issue has been resolved in version 2.12.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants