Skip to content

Admin collection level validation #307

Answered by rpfaeffle
wezzle asked this question in Q&A
Discussion options

You must be logged in to vote

As far as I know, there is no possibility to validate a collection directly, based on the properties you hand over to fields. But you could use a BeforeValidateHook to check whether a link has been provided or not. The only problem with this is that you have to make both of the fields optional and cannot directly show the user that the field is required (except you're using a custom component). But you could throw and error message using payloads ApiError to provide the user with context why it failed to save.

I've created a simple example using a checkbox and a textfield:

const Collection = {
  slug: 'my-collection',
  fields: [
    {
      name: "checkbox",
      type: "checkbox",
    },

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@wezzle
Comment options

Answer selected by zubricks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants