IRuleSet.ValidateAllTargets(IObjectSpace, IEnumerable, ContextIdentifiers) 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.v25.2.dll
NuGet Package: DevExpress.Persistent.Base
Declaration
RuleSetValidationResult ValidateAllTargets(
IObjectSpace targetObjectSpace,
IEnumerable targets,
ContextIdentifiers contextIDs
)
Parameters
| Name | Type | Description |
|---|---|---|
| targetObjectSpace | IObjectSpace | An IObjectSpace used by a validation target. |
| targets | IEnumerable | The list of objects to check. |
| contextIDs | ContextIdentifiers | The ContextIdentifiers object, which is a set of validation contexts for which rules will be collected. Default contexts are stored in the DefaultContexts enumeration. |
Returns
| Type | Description |
|---|---|
| DevExpress.Persistent.Validation.RuleSetValidationResult | The validation result. If all rules are satisfied, the |
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), ContextIdentifier.Save);
ValidationResults obj = new ValidationResults(validationResult, base.Application.Model);
bool flag = validationResult.State != ValidationState.Invalid;
}
}
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the ValidateAllTargets(IObjectSpace, IEnumerable, ContextIdentifiers) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.