Quantcast
Channel: Developer to developer
Viewing all articles
Browse latest Browse all 9076

Custom validation for «Manage Expiration and Archiving».

$
0
0

I am well aware of how custom validation of regular properties can be done, but how can I validate the input in the window for «Manage Expiration and Archiving»?

I would like to make «Archive to» required for some page types, if «Expire date» has a value.

I have tried adding this:

public class ExpirePageValidator : IValidate
{
    IEnumerable IValidate.Validate(ExpirePage page)
    {
        if (page.StopPublish != null && page.ArchiveLink == PageReference.EmptyReference)
        {
            return new[]
            {
                new ValidationError
                {
                    ErrorMessage = "Varför gör ni på detta viset?",
                    PropertyName = page.GetPropertyName(page => page.ArchiveLink),
                    Severity = ValidationErrorSeverity.Warning,
                    ValidationType = ValidationErrorType.AttributeMatched
                }
            };
        }
          return Enumerable.Empty();
    }
}


The code runs when the expiration date are saved, but the validation message are not shown until other changes are published. Most of the time there are no other changes, so the validation message will never be shown.

How can I solve this?


Viewing all articles
Browse latest Browse all 9076

Trending Articles