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:
app.customFields.register({
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 () =>
import(
/* 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.
Thanks