#v2 upgrade error in logs when running dev, "value" does not match

1 messages · Page 1 of 1 (latest)

digital shard
#
[14:58:27] ERROR (payload): There were 4 errors validating your Payload config
[14:58:27] ERROR (payload): 1: Collection "components" > Field "blocks" > "value" does not match any of the allowed types
[14:58:27] ERROR (payload): 2: Collection "pages" > Field "blocks" > "value" does not match any of the allowed types
[14:58:27] ERROR (payload): 3: Global "user-context-content" > Field "policySearchContent" > "value" does not match any of the allowed types
[14:58:27] ERROR (payload): 4: Global "user-context-content" > Field "originalPolicyProviderContent" > "value" does not match any of the allowed types

For example here's the relevant code:

payload.config.ts


export default buildConfig({
    admin: {
        bundler: webpackBundler(),
        user: Users.slug,
        meta: {
            titleSuffix: `- ${siteTitle}`,
        },
    },
    editor: slateEditor({}),
    // getMongoOptions ?
    db: mongooseAdapter({
        url: process.env.MONGO_URI ? process.env.MONGO_URI : false,
    }),
    // lexical editor?
    collections: [Component, FormidableForm, Media, OriginalPolicyProvider, Page, Topic, TopicType, Users],
    ...
    globals: [
        FooterMenu,
        HomePage,
        OriginalPolicyProviderOptions,
        PolicySearchMappings,
        PublicAccess,
        SubMenu,
        UserContextContent,
    ],
   ...
});
limber stagBOT
digital shard
#

userContextContent


const UserContextContent: GlobalConfig = {
    slug: 'user-context-content',
    access: {
        read: () => true,
        update: userHasContentAdministratorRole,
    },
    graphQL: {
        name: 'userContextContent',
    },
    fields: [
        title({
            admin: {
                description: `The heading the user sees when prompted for policy number or original policy provider details`,
            },
            defaultValue: 'Request policy information',
        }),
        {
            name: "test",
            type: "richText",
            label: "Test",
            admin: {
                description: `The heading the user sees when prompted for policy number or original policy provider details`,
                // elements: [
                //     "h1",
                //     "h2",
                //     "h3",
                //     "h4",
                //     "h5",
                //     "h6",
                // ],
                // leaves: ["bold", "italic"],
            },
        },
       
        richText({
            name: 'policySearchContent',
            label: 'Policy search content',
            admin: {
                description: `The content displayed to the user when prompted for their policy number. If this field is empty, the content will default to the original copy.`,
            },
        }), 
       
    ],
};
#

If I bring back the commentted lines elements and leaves the test richText field will also error similarly to the other richText fields

#

As we use a richText helper function I'd like to get the example, sourced from Payload docs, working because I can then abstract the fix into that helper

#

I'm not sure why:

  • the richText field is returning this error
  • the blocks value is not allowed ( it is a array of blocks? )
digital shard
#

Worked out the richText issue - the blocks one remains

#

for anyone observing this in the future, to use the Slate editor you need to do both:

  • import the editor to the payload config
  • add the editor to the richText component

worth noting to include the types to avoid ts issues via

import type { RichTextElement, RichTextLeaf } from '@payloadcms/richtext-slate'

digital shard
#

got it in the end 💪