Virtual Happy Hour is canceled this month (March) due to Good Friday.
Try our conversational search powered by Generative AI!
AI OnAI Off
Virtual Happy Hour is canceled this month (March) due to Good Friday.
You can create your own validator class by implementing EPiServer.Validation.IContentSaveValidate<T>. You cn find more info here https://world.episerver.com/documentation/developer-guides/CMS/Content/Validation/
Remove the required-attribute on DownloadPdfText, and add this class. Change CustomBlockType to your blocktype.
public class CustomBlockValidator : IValidate<CustomBlockType> { IEnumerable<ValidationError> IValidate<CustomBlockType>.Validate(CustomBlockType customBlockType) { if (customBlockType.DisplayPdfButton && string.IsNullOrEmpty(customBlockType.DownloadPdfText)) { return new[] { new ValidationError { ErrorMessage = "You can't hava a button without text, stupid!", PropertyName = CustomBlockType.GetPropertyName(block => block.DownloadPdfText), Severity = ValidationErrorSeverity.Error, ValidationType = ValidationErrorType.AttributeMatched } }; } return Enumerable.Empty<ValidationError>(); } }
I have a Block Type wich has these two properties.
I only want DownloadPdfText to be required if the user sets DisplayPdfButton to True. - Is this possible to do in Episerver?