[Remote] attribute requirements (#12632)

pull/12636/head
Tom Dykstra 2019-06-01 14:37:08 -07:00 committed by GitHub
parent fc3d17dbb0
commit a5a35ecc89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -116,7 +116,9 @@ To implement remote validation:
1. In the model class, annotate the property with a `[Remote]` attribute that points to the validation action method, as shown in the following example:
[!code-csharp[](validation/sample/Models/User.cs?name=snippet_UserEmailProperty)]
The `[Remote]` attribute is in the `Microsoft.AspNetCore.Mvc` namespace. Install the [Microsoft.AspNetCore.Mvc.ViewFeatures](https://www.nuget.org/packages/Microsoft.AspNetCore.Mvc.ViewFeatures) NuGet package if you're not using the `Microsoft.AspNetCore.App` or `Microsoft.AspNetCore.All` metapackage.
### Additional fields
The `AdditionalFields` property of the `[Remote]` attribute lets you validate combinations of fields against data on the server. For example, if the `User` model had `FirstName` and `LastName` properties, you might want to verify that no existing users already have that pair of names. The following example shows how to use `AdditionalFields`: