Skip to main content

ValidationModule.InitializeRuleSet() Method

Initializes the RuleSet object assigned to the DevExpress.Persistent.Validation.Validator.RuleSet property.

Namespace: DevExpress.ExpressApp.Validation

Assembly: DevExpress.ExpressApp.Validation.v26.1.dll

NuGet Package: DevExpress.ExpressApp.Validation

Declaration

public void InitializeRuleSet()

Remarks

Note

In v23.1 and higher, you do not need to use the InitializeRuleSet method in .NET Core-based applications (both Blazor and WinForms). All required initialization is done automatically.

The Validation Module calls this method on logon and when a user closes the Model Editor at runtime. To initialize validation rules before the main window is displayed and a user logs into the application, follow the steps below:

  1. Override the ModuleBase.Setup method in a platform-specific (MySolution.Blazor.Server, MySolution.Win, MySolution.Web) or platform-agnostic (MySolution.Module)project.
  2. In this overridden method, handle the XafApplication.SetupComplete event.
  3. In the event handler, access the Validation Module and call the InitializeRuleSet method.

File: MySolution.Module\Module.cs.

using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Validation;
// ...
public sealed class MySolutionModule : ModuleBase {
    public override void Setup(XafApplication application) {
        base.Setup(application);
        application.SetupComplete += Application_SetupComplete;
    }
    private void Application_SetupComplete(object sender, EventArgs e) {
        ValidationModule module = (ValidationModule)Application.Modules.FindModule(typeof(ValidationModule));
        if(module != null) {
            module.InitializeRuleSet();
        }
    }
    // ...
}
See Also