Try our conversational search powered by Generative AI!

Page & block publishing and validation rules.

Vote:
 

I have a question regarding publishing blocks and publishing pages; that is, how I control validation on when a block can be published, and when a page can be published.

I want to be able have a set of criteria that are imposed in order that a block can be published. I think this is done using property level validation; mandatory, not mandatory etc.

However, a  page can consist of multiple blocks, some of which are mandatory for a page, and others are optional.  

How do I validate  page publishing validation based on block "state".

Thanks in advance. 

Barry

#148401
May 12, 2016 4:57
Vote:
 

Hi,

Maybe you can prepare a custom validator like:

public class CustomPageValidator : IValidate<MyPageType>
{
   IEnumerable<ValidationError> IValidate<MyPageType>.Validate(MyPageType page)
   {
      bool blocksValidationCondition = .... validation condition ....
	  if (!blocksValidationCondition)
      {
         return new[] 
         { 
            new ValidationError() 
            { 
               ErrorMessage = "Cannot publish page", 
               PropertyName = page.GetPropertyName(pg => pg.IntroText),
               Severity = ValidationErrorSeverity.Warning, 
               ValidationType = ValidationErrorType.AttributeMatched
            } 
         };
      }		

      return Enumerable.Empty<ValidationError>();
   }
} 
#148402
May 12, 2016 7:25
* 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.