Try our conversational search powered by Generative AI!

Update existed custom criteria value, invalid but saved successfully

Fixed in

EPiServer.CMS.Core 10.1.0

(Or a related package)

Created

Aug 18, 2016

Updated

Nov 14, 2016

Area

CMS Core

State

Closed, Fixed and tested


Description

Steps to reproduce

1. Use code snippet bellow to create custom visitor group criteria.

public class CustomCriterionSettings : CriterionModelBase, IValidateCriterionModel
{
public string MyCustomProperty { get; set; }
 
public override ICriterionModel Copy()
{
return ShallowCopy();
}
 
public CriterionValidationResult Validate(VisitorGroup currentGroup)
{
if (MyCustomProperty == "dummyvalue")
{
return new CriterionValidationResult(false, "Invalid criteria value");
}
return CriterionValidationResult.Valid;
}
}
 
[VisitorGroupCriterion(Category = "Custom Category",DisplayName = "Custom Criterion",Description = "A descirption")]
public class CustomCriterion : CriterionBase<CustomCriterionSettings>
{
public override bool IsMatch(IPrincipal principal, HttpContextBase httpContext)
{
return true;
}
}

2. Create new Visitor Group.
3. Add CustomCriteria with value != "dummyvalue".
4. Click Save.
5. Reopen the recently-created Visitor Group, change the value of CustomCriteria = "dummyvalue".

Expected: Error message shown and VisitorGroup is not saved.
Actual: Error message shown but VisitorGroup is saved successfully.