Skip to main content
.NET 6.0+

RuleSet Class

Specifies a set of Validation Rules that can be checked on an object.

Namespace: DevExpress.Persistent.Validation

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

Declaration

public class RuleSet :
    IRuleSet,
    IEnumerable<IRule>,
    IEnumerable

Remarks

Validation is based on rules declared in business class code and in the Validation node of the Application Model. Internally, these rules are automatically collected in the RuleSet.RegisteredRules property of the Validator.RuleSet object. The rules are checked automatically when saving and deleting objects and when an Action with the appropriate validation context is executed. If you need to modify the default behavior, you can access an instance of the RuleSet class via the static Validator.RuleSet property and then call the RuleSet methods or subscribe to the RuleSet events.

The following example demonstrates how to trigger the validation against a specific object and context, and then handle the result.

private void RuleSetExampleController_Activated(object sender, EventArgs e) {
    RuleSetValidationResult result = Validator.RuleSet.ValidateTarget(View.ObjectSpace, View.CurrentObject, "MyContext");
    if (result.ValidationOutcome > ValidationOutcome.Information)
        ((Contact)View.CurrentObject).Notes += "[Validation Error] " + result.Results[0].ErrorMessage;
}

Normally, you should not create instances of the RuleSet class manually, because if you validate a custom RuleSet, rules from the Validator.RuleSet will be ignored and the validation result may be invalid.

Inheritance

Object
RuleSet
See Also