Apply validation to custom field

System Information
  • Strapi Version: 4.9.0
  • Operating System: Windows10
  • Database: MySQL
  • Node Version: 16.16.0
  • NPM Version: 8.11.0
  • Yarn Version: -

Hey all,

I am facing an issue after adding validation to the custom fields. I have read the docs and followed the example on adding yup validations to a custom plugin field but it isn’t working for me.

This is the plugin register code which I am using:

  name: "custom-slug",
  pluginId: "custom-slug",
  type: "string",
  intlLabel: {
    id: "slug.form.label",
    defaultMessage: "Slug Custom Field",
  intlDescription: {
    id: "slug.form.description",
    defaultMessage: "Autogenerated Custom Slug",
  icon: PluginIcon,
  components: {
    Input: async () =>
        /* webpackChunkName: "input-component" */ "./components/Input"
  options: {
    base: [],
    advanced: [
        sectionTitle: {
          id: 'global.settings',
          defaultMessage: 'Settings',
        items: [
            name: 'required',
            type: 'checkbox',
            intlLabel: {
              id: 'form.attribute.item.requiredField',
              defaultMessage: 'Required field',
            description: {
              id: 'form.attribute.item.requiredField.description',
              defaultMessage: "You won't be able to create an entry if this field is empty",
    validator: args => ({
     required: yup.boolean({
        defaultMessage: "This field is required",

Has anyone really applied validations to their custom developed plugin field? Also, I would like to have a unique field value validation too with it.

Any help would be appreciated.


Answering from the Strapi 4.13.7
You don’t need the custom validator in this case, because the required (and also unique, regex, max-min length) validator is handled by strapi.

If you didn’t find any typo or smth and still didnt find the solution can you show an example from schema.json where you have added your custom field with ‘Required’ option checked?

Thanks for the reply.

I have kept the above work on hold long time ago due to other priorities but will surely get back to you once I shift back to the custom plugin field in near future.