IDocumentHandler

The IDocumentHandler interface allows you to create custom logic which can be applied to models.  The interface allows you to create custom validation logic which is performed when documents are added and/or updated.  The Validate() method has a default implementation so you don't have to implement it - usually the IDocumentHandler interface is used in conjuction with the IDocumentAddedHandler, IDocumentUpdatedHandler or IDocumentDeletedHandler interfaces to further specify what it does.

Interface declaration

/// <summary>
/// Document handlers can be executed when changes are made to documents in the model they have been applied to
/// This is the base interface all handlers must implement.  It allows you to provide a custom validation logic.
/// Additional interfaces are available:
///		- IDocumentAddedHandler - Execute actions before and after a document is added
///		- IDocumentUpdatedHandler - Execute actions before and after a document is updated
///		- IDocumentDeletedHandler - Execute actions before and after a document is deleted
///		- IManuallyTriggeredHandler - Execute actions manually by pressing a button.  Runs for the entire model, not single documents.
/// </summary>
public interface IDocumentHandler
{
	/// <summary>
	/// Is executed before adding/updating and allows for custom validation logic
	/// </summary>
	/// <param name="document">The document which is being added/updated</param>
	/// <returns>A list of validation messages.  Return null or an empty list if the validation was successful</returns>
	List<ValidationMessage> Validate(Document document) => null;					
}

Example

No example here, see the other document handler interfaces for examples.

Registration

This is how the implementation is registered into the DI container in Veva, this should be done in your module config file (The class which implements IModule).

No registration example here, see the other document handler interfaces.