New to Plone development, I currently have a problem with a form validation when adding an object with the default Add form.
To validate a field from my custom Interface implementing plone.supermodel.model.Schema, I need to check the field value for all the other objects of the same type.
These objects are in different folders, and depending on the folder, the validation will be different.
The field should be unique by folder, and I don't want any auto-renaming, the user should rename it himself (so validation error).
It should be enough for me to get the folder where the future object will be added, or the current URL of the form (folder name will be in it).
I tried the validation in an zope.interface.invariant, but I only have access to the z3c.form.validator.Data object, which contains no useful info for me.
I hope I can perform validation at the Add button click, and not after it (in an zope.lifecycleevent.IObjectAddedEvent event handler for exemple), because I really want to be able to prevent the addition, and not alter the field.
Can someone give me any clue on where to look to achieve this ?