First i will clarify why we should integrate both client and server side validation for three main reasons :
- client side validation does not require any async call to validate information. is smoother for user experience.
- Server side validation is obligation for security reason.
- Server side can add business form validation (You enter new user, in server you can check if this user nam is not already taken).
Then about your question. include Server side validation error message on your reactive form looks to be great idea (especially for last reason above).
For that, as pruposed by your link, you should take adventage of HTTP status code who will help you to categorize your error type. Then you have to design generic ErrorResponseBag
. For Example (and is just example easy to understand), MangoPay API have bellow schema for error reporting :
{
"resultCode" : 1234,
"ResultMessage" : "some message",
"MoreInformation" : "Optional extra information"
}
ResultCode : Is number who make reference to specific constant type error.
Then is easy to create EasyErrorHandler
who intercept each HttpErrorResponse
and put it on Alert or what ever.
Sample of HttpInterceptor in StackBlitz
source for mangopay
Note : if you need more information about HttpInterceptor file free to ask me