More explicit analogy
- "... to validation of fields in **database** tables."pull/1223/merge
parent
1429225157
commit
370208aa41
|
@ -18,7 +18,7 @@ Fortunately, .NET has abstracted validation into validation attributes. These at
|
|||
Validation Attributes
|
||||
---------------------
|
||||
|
||||
Validation attributes are a way to configure model validation so it's similar conceptually to validation on fields in tables. This includes constraints such as assigning data types or required fields. Other types of validation include applying patterns to data to enforce business rules, such as a credit card, phone number, or email address. Validation attributes make enforcing these requirements much simpler and easier to use.
|
||||
Validation attributes are a way to configure model validation so it's similar conceptually to validation on fields in database tables. This includes constraints such as assigning data types or required fields. Other types of validation include applying patterns to data to enforce business rules, such as a credit card, phone number, or email address. Validation attributes make enforcing these requirements much simpler and easier to use.
|
||||
|
||||
Below is an annotated ``Movie`` model from an app that stores information about movies and TV shows. Most of the properties are required and several string properties have length requirements. Additionally, there is a numeric range restriction in place for the ``Price`` property from 0 to $999.99, along with a custom validation attribute.
|
||||
|
||||
|
@ -202,4 +202,4 @@ The second step is putting the validation code in the corresponding action metho
|
|||
:language: c#
|
||||
:lines: 6-23
|
||||
|
||||
Now when users enter an email, JavaScript in the view makes a remote call to see if that email has been taken, and if so, then displays the error message. Otherwise, the user can submit the form as usual.
|
||||
Now when users enter an email, JavaScript in the view makes a remote call to see if that email has been taken, and if so, then displays the error message. Otherwise, the user can submit the form as usual.
|
||||
|
|
Loading…
Reference in New Issue