Creating client-side logic for custom validation

The custom validator we created in this chapter should provide client-side validation support as well. By default, EF will only perform server-side validation (out of the box), but the client-side validation should be performed manually. The framework has provision to inject custom validation and its errors in the context attributes. However, we need to perform/implement client-side validation on our own.

The FutureOnly custom validation attribute can be configured to support client-side validation using IClientModelValidator, which expects us to implement the AddValidation method. We should be injecting the required custom validation values in the context attributes; the required implementation ...

Get Mastering Entity Framework Core 2.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.