Deny creation of two objects with the same title in a folder

This is more a curiosity than an issue: in a folder, I can create two objects with the same title (the ids are different).

Is it possible to block the creation of an object that has the same title of an existing object in the same folder?

I think not, but if I wanted to do that[*], what should I modify?

The only thing that comes to my mind is a custom validation of the title field of all content types at creation, but it doesn't seem to me a good idea (e.g. new content types would probably break this solution).

ATM I'm interested only in the theory :slight_smile:

[*] If I wanted to impose this restriction, I guess I'd need to take care of "editing" of the objects also.

my first thought: handling via subscribers or via invariant in a custom add/edit form.

You can do a class that is@implementer(INameChooser) and fail with ValueError if your conditions are not met. An example:

plone.app.content/plone/app/content/namechooser.py at 5568d0e1916925d7efd3a696c82b7ae66b41c30c · plone/plone.app.content · GitHub (the code also check if the INameFromTitle behavior is applied to the object and use it.

<adapter
      factory=".namechooser.NormalizingNameChooser"
      provides="zope.container.interfaces.INameChooser"
      for="Products.CMFCore.interfaces.IFolderish"
      />