Skip to content

Conversation

@akhrarovsaid
Copy link
Contributor

What?

This PR adds the RichTextFieldValidation type to the validate property of the RichTextField.

Why?

Previously, adding the default richText validate function to a typical type: 'richText' field would result in a TS error due to mismatching types, specifically on the options argument. With these changes, you can now simply thread the default richText validation through to the validate property as expected with no unnecessary type manipulation.

Previously, this would result in a TS error:

import type { CollectionConfig } from 'payload'

import { richText } from 'payload/shared'

export const PostsCollection: CollectionConfig = {
  slug: 'posts',
  // ...
  fields: [
    // ...
    {
      name: 'content',
      type: 'richText',
      validate: richText, // Type error here
    },
  ],
}

With the changes introduced here, the TS error is resolved.

How?

By threading the existing RichTextFieldValidation type to the validate property of the RichTextField.

Fixes #15068

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Types for default richText validation function is not compatible with what validate provides

1 participant