I got a question from a customer today which got me thinking. The use case is that they want to quickly create pages, i.e have very few required properties.
They are fine with the pages being sort of empty while in Draft. But when they go ahead and Publish the content, there are more properties that must have values.
How would I go about this? There's the OnPublishing-event where one could check values on said properties, or one could extend the Required-attribute and make it take a Status-flag, or...
Pros/cons? stupid idea altogether?
Take a look at implementing a validator based on IContentSaveValidate interface.
Then you will get in a context that contains the SaveAction meaning you can have different validation based om which SaveAction it is (e.g Publish)
Thanks! Looks like a nice approach.
I blogged about that very same idea: https://www.david-tec.com/2017/07/hiding-required-properties-on-the-create-new-page-in-episerver/