Take the community feedback survey now.
AI OnAI Off
Take the community feedback survey now.
Hi,
I've built a number of custom IValidate classes and have never experienced such issues. I have however never set anything else than ErrorMessage and PropertyName on my ValidationErrors. I usually also return Enumerable.Empty<ValidationError>(). Neither of those differences should matter though.
Hi Marija
I had same problem as you had, I can't recreate it, but it did happen few times to me.
Now, I have changed it to return Enumerable.Empty<ValidationError>(); and tried out a couple of times with this and return null.
Every time return null gives me the problem described and return Enumerable.Empty<ValidationError>(); gives me the correct behavior.
Hi, guys,
Have you tried out EPi 7's custom validation?
The error is returned when the validation condition is broken. However, when I fix the thing that is causing the validation error, auto save always returns: "Offline, can't save" and hitting Publish, gives me the validation error.
This is the code:
public class RowBlockValidator : IValidate<RowBlock> { IEnumerable<ValidationError> IValidate<RowBlock>.Validate(RowBlock instance) { if (instance.OneToFourBlocks != null) { if (instance.OneToFourBlocks.Count > 4) { var validationError = new ValidationError { ErrorMessage = "Content area can contain up to four blocks", PropertyName = "OneToFourBlocks", RelatedProperties = new string[] { "OneToFourBlocks" }, Severity = ValidationErrorSeverity.Error, ValidationType = ValidationErrorType.AttributeMatched }; return new[] {validationError}; } } return null; } }