P26 input validation and Data Annotations



4 is a status code beginning of the consumer caused the beginning of the 5 server error. In the rest service which, in response error is usually placed inside the body. body which includes a set of error. api consumers can put these errors demonstrate to the client.








Start writing code

Create a request of the company, deliberately passing json data null values.

500 returned an error


in response to the error message body which contains the



required name attribute value, we define RoutingDbContext inside.

Here returned status code indicates the beginning of the 500.5 server error.

Because of this error is actually caused by our consumers, it sends a wrong property value. So the state should return to the beginning of the 4 fishes.

So we want to pass parameters to verify.

There are a lot of this namespace Attribute

plus the length limit



after the finish, then test


plus ErrorMessage



also can return a little more friendly. {0} to represent the current attribute name






{1} {2} represents the maximum length represented by the minimum length



End

 

Guess you like

Origin www.cnblogs.com/wangjunwei/p/12548140.html