How to validate only on publish event?


Using Episerver CMS 9 is there a way to only perform validation of a page when publishing and not on autosave?

We wish to let the editors leave the content in a invalid state when it's work in progress.

Implementing validation as suggested by the documentation using (IValidate) leads to validation to occur on autosave.

Implementing a (MVC) ValidationAttribute and decorating my properties with also seems to be validated during autosave.

What's the solution?

Hoping for something other than this =)

Mar 16, 2016 14:36

You could add a validation on the publishing event. This will trigger before the pages is actually published.

Here is an example.

Mar 16, 2016 16:42

Thanks for the suggestion Niklas, I might have to do it that way I guess.

But I would prefer a solution where I get to keep the validation rules as attributes together with my models (pages etc) without them being processed on the save event.

It would be nice if Episerver could let us specify the events for when to validate an instance of a contenttype.

#FeatureRequest ;)

public class StandardPage : PageData

Mar 16, 2016 17:36
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.