diff --git a/docs/en/Validation.md b/docs/en/Validation.md index c4821adf65..1d24c5e2a6 100644 --- a/docs/en/Validation.md +++ b/docs/en/Validation.md @@ -149,8 +149,8 @@ Once ABP determines a validation error, it throws an exception of type `AbpValid In addition to the automatic validation, you may want to manually validate an object. In this case, [inject](Dependency-Injection.md) and use the `IObjectValidator` service: -* `Validate` method validates the given object based on the validation rules and throws an `AbpValidationException` if it is not in a valid state. -* `GetErrors` doesn't throw an exception, but only returns the validation errors. +* `ValidateAsync` method validates the given object based on the validation rules and throws an `AbpValidationException` if it is not in a valid state. +* `GetErrorsAsync` doesn't throw an exception, but only returns the validation errors. `IObjectValidator` is implemented by the `ObjectValidator` by default. `ObjectValidator` is extensible; you can implement `IObjectValidationContributor` interface to contribute a custom logic. Example: @@ -158,13 +158,14 @@ In addition to the automatic validation, you may want to manually validate an ob public class MyObjectValidationContributor : IObjectValidationContributor, ITransientDependency { - public void AddErrors(ObjectValidationContext context) + public Task AddErrorsAsync(ObjectValidationContext context) { //Get the validating object var obj = context.ValidatingObject; //Add the validation errors if available context.Errors.Add(...); + return Task.CompletedTask; } } ```` diff --git a/docs/zh-Hans/Validation.md b/docs/zh-Hans/Validation.md index f6b2daf31f..6e46b07aed 100644 --- a/docs/zh-Hans/Validation.md +++ b/docs/zh-Hans/Validation.md @@ -130,8 +130,8 @@ namespace Acme.BookStore 除了自动验证你可能需要手动验证对象,这种情况下[注入](Dependency-Injection.md)并使用 `IObjectValidator` 服务: -* `Validate` 方法根据验证​​规则验证给定对象,如果对象没有被验证通过会抛出 `AbpValidationException` 异常. -* `GetErrors` 不会抛出异常,只返回验证错误. +* `ValidateAsync` 方法根据验证​​规则验证给定对象,如果对象没有被验证通过会抛出 `AbpValidationException` 异常. +* `GetErrorsAsync` 不会抛出异常,只返回验证错误. `IObjectValidator` 默认由 `ObjectValidator` 实现. `ObjectValidator`是可扩展的; 可以实现`IObjectValidationContributor`接口提供自定义逻辑. 示例 : @@ -140,13 +140,14 @@ namespace Acme.BookStore public class MyObjectValidationContributor : IObjectValidationContributor, ITransientDependency { - public void AddErrors(ObjectValidationContext context) + public Task AddErrorsAsync(ObjectValidationContext context) { //Get the validating object var obj = context.ValidatingObject; //Add the validation errors if available context.Errors.Add(...); + return Task.CompletedTask; } } ````