I am new to EPiServer. I am using IValidate interface for validating the default property of episerver page i.e CategoryList. I would like to restrict the count of category selection for example say only one category should be selected. I did this for a single pagetype, But i am getting the following exception , while adding additional page types,"Ambiguous match found". It may be simple one i may not know. I have attached my code below.
public class BasePageValidator : IValidate,IValidate
IEnumerable IValidate.Validate(SamplePage page)
if (page != null && page.Category.Count > 1)
ErrorMessage = "Field IntroText cannot be empty!",
PropertyName = page.GetPropertyName(pg => pg.Category),
Severity = ValidationErrorSeverity.Warning,
ValidationType = ValidationErrorType.AttributeMatched
IEnumerable IValidate.Validate(Products page)
It is not working after adding "IValidate", getting an exception.
I need to set this restriction for some pagetypes more than one. Suggest me on how to achive this one.
Thanks in advance.
If I remember correctly IValidate supports being registered against interfaces. So you could add an interface to SamplePage and Products, something like IMustHaveCategory, and then register your validator as IValidate<IMustHaveCategory>. Would that work?
Is it possible to highlight a field with yellow colour if it fails validation with severity warning. Currently, only for severity Error it highlights the field with red colour, ex: Required field validation.