.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
.NET 5.0+

RuleBaseAttribute.TargetCriteria Property

Specifies a criterion that must be satisfied by the validated object or property to check rules.

Namespace: DevExpress.Persistent.Validation

Assembly: DevExpress.Persistent.Base.v21.2.dll


public string TargetCriteria { get; set; }

Property Value

Type Description

A string that represents a criterion that must be satisfied to check validation rules.


When defining a rule for a business class or property, you should specify a context for checking this rule. In some scenarios, you may need to check whether a criterion is satisfied by the object or property before checking the rule. For instance, the RuleRequiredField rule can be checked for the SpouseName property, if the IsMarried property is set to true. The following code sample demonstrates how to define this rule.

public class Contact {
    // ...
    [RuleRequiredField("SpouseNameIsRequiredWhenMarried", DefaultContexts.Save,
       SkipNullOrEmptyValues = false, TargetCriteria = "[IsMarried] == True")]
    public String SpouseName { get; set; }
    public bool IsMarried { get; set; }
    // ...


You can use Function Criteria Operators when passing a criteria as the TargetCriteria parameter. For details on how to write a criteria, refer to the Ways to Build Criteria topic.


See Also