Skip to main content
.NET 8.0+

RuleSet Class

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

Namespace: DevExpress.Persistent.Validation

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

Declaration

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

Remarks

Note

This is a legacy class. In new applications that target .NET, use IRuleSet instead.

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 DevExpress.Persistent.Validation.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 use the static DevExpress.Persistent.Validation.Validator.RuleSet property to access an instance of the RuleSet class, and then call RuleSet methods or subscribe to RuleSet events.

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

private void RuleSetExampleController_Activated(object sender, EventArgs e) {
    IRuleSet ruleSet = Validator.GetService(Application.ServiceProvider);
    RuleSetValidationResult result = 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 DevExpress.Persistent.Validation.Validator.RuleSet will be ignored and the validation result may be invalid.

Implements

Inheritance

Object
RuleSet
See Also