Validation on Entry during publishing

We have requirement to Validate entries before publishing, such that there can be only one entry for a particular content model in published state. Can this be achieved? If so how?

Hi @makeshkumar.b,

It sounds like you’d like to create a singleton entry. So for a particular content type, there can only be one entry of that type. This can be useful when creating a menu component.

One way to achieve this is by using field validations. For example, for a content type called myContentType you could include a slug field. In the validation for that slug field, make it required, unique, and set a default value. In your code, you are fetching that default value for the slug field for myContentType.

This will disallow content authors from creating a second entry of myContentType that could be rendered by the frontend. If they want to replace the rendered entry, they need to update the slug field on the current entry to not be the default value, and then enter the default value for the new entry.

Hope that helps!

Thanks this is good idea.