.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
.NET Core 3.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.v19.2.dll

Declaration

public string TargetCriteria { get; set; }
Public Property TargetCriteria As String
public string TargetCriteria { get; set; }
Public Property TargetCriteria As String
public string TargetCriteria { get; set; }
Public Property TargetCriteria As String

Property Value

Type Description
String

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

Property Value

Type Description
String

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

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.

See Also