Feature Request
Proposed API:
public class MyValidationAttribute : AsyncValidationAttribute
{
protected override async Task<ValidationResult> IsValidAsync(object value, ValidationContext validationContext, HttpContext httpContext)
{
var db = httpContext.RequestServices.GetRequiredService<MyDbContext>();
}
}
Introduce new validation attribute for asynchronously validating a model. The method should:
Be async to allow await-ing asynchronous validations. For example: against a database table.
Accept HttpContext as parameter, to allow implementer to pull application services.
This feature will allow organizing validations purely in attributes, instead of having some validations in attributes and some in controllers.
Microsoft.AspNetCore.Mvc or Microsoft.AspNetCore.App or Microsoft.AspNetCore.All:-
Thanks for contacting us, @ryanelian.
@glennc is this something we'd be interested in doing?
/cc @rynowak, @danroth27
Hi. Thanks for contacting us.
We're closing this issue as there was no much community interest in supporting async validation. May the situation change in the future we may reconsider this.
Hello.
Please reconsider, we would benefit from this too.
Thanks!
Up, we had some cases in which we needed async validation too.
I am also wanting this.