Skip to main content
A newer version of this page is available. .

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.v18.2.dll

Declaration

public string TargetCriteria { get; set; }

Property Value

Type Description
String

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

Remarks

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; }
    // ...
}

Note

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.

Implements

See Also