Does ASP.NET Web API support IValidatableObject?

I have a view model that implements IValidatableObject, and also has several validation attributes. When I try to invoke an action on my ApiController, only an attribute check is performed. Doesn't support ASP.NET API IValidatableObject? What is an alternative to complex validation that cannot be represented by a single attribute?

Edit: Somewhere along the line, I must have faked something. Validation mysteriously began to work as expected. It appears that IValidatableObject is definitely supported by default.

+5
source share
3 answers

IValidatableObject webapi, , Validation DataAnnotations (DataAnnotationsModelValidatorProvider) IValidatableObject. . : http://msdn.microsoft.com/en-us/library/system.web.http.validation.providers(v = vs .108)

ValidationAttribute , ... , IValidatableObject, .

+1

Web API 2.1 (Microsoft.AspNet.WebApi nuget 5.1.x) ValidalidableBlate Validate, , - . , , , , .

, , RequiredAttribute, , IValidatableObject Validate . , , Validate , .

+4

Currently supported IValidatableObject.

0
source

All Articles