Try our conversational search powered by Generative AI!

How to validate only on publish event?

Vote:
 

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 =)

http://world.episerver.com/forum/developer-forum/EPiServer-7-CMS/Thread-Container/2013/5/How-to-prevent-validator-from-triggering-on-autosave/

#146493
Mar 16, 2016 14:36
Vote:
 

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

Here is an example.

http://world.episerver.com/blogs/Janaka-Fernando/Dates/2015/4/adding-custom-logic-to-your-publishing-step/

#146503
Mar 16, 2016 16:42
Vote:
 

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 ;)

[ValidateOn(ContentEvents.PublishingContent)]
public class StandardPage : PageData

#146507
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.