Skip to main content
.NET Framework 4.6.2+

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

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

The following members return RuleSet objects:

#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.

C#
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