Skip to main content
All docs
V24.1
.NET Framework 4.5.2+

IRuleSet.ValidateAllTargets(IObjectSpace, IEnumerable) Method

Silently (without raising the RuleSet.ValidationCompleted event and throwing the ValidationException) validates multiple targets and returns the result.

Namespace: DevExpress.Persistent.Validation

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

Declaration

RuleSetValidationResult ValidateAllTargets(
    IObjectSpace targetObjectSpace,
    IEnumerable targets
)

Parameters

Name Type Description
targetObjectSpace IObjectSpace

An IObjectSpace used by validation targets.

targets IEnumerable

The list of objects to check.

Returns

Type Description
DevExpress.Persistent.Validation.RuleSetValidationResult

The result of the RuleSet validation.

Remarks

The following code snippet demonstrates how to use this method to validate objects when an Action is executed:

using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.Validation;
// ...
public partial class CustomValidationController : ViewController {
    public CustomValidationController() {
        SimpleAction validationAction = new SimpleAction(this, "ValidateBeforeSave", PredefinedCategory.Edit);
        validationAction.Execute += ValidationAction_Execute;
    }
    private void ValidationAction_Execute(object sender, SimpleActionExecuteEventArgs e) {
        RuleSetValidationResult validationResult = Validator.GetService(Application.ServiceProvider)
            .ValidateAllTargets(ObjectSpace, ObjectSpace.GetObjectsToSave(false));
        ValidationResults obj = new ValidationResults(validationResult, base.Application.Model);
        bool flag = validationResult.State != ValidationState.Invalid;
    }
}
See Also