Angular 2 (Beta) Server side validation messages -


i looking elegant way display validation messages server side api without having create custom validators or hard coding possible messages in ui.

i need add error messages specific fields entire form.

this must work in angular 2.0.0-beta.3

i present definitive displayerrors function (handles server side validations following jsonapi standard):

you need underscore.js

displayerrors(error: errorresponse) {   let controls = this.supportrequestform.controls;   let grouped = _.groupby(error['errors'], function(e) {     return e['source']['pointer'];   });   _.each(grouped, function(value, key, object) {     let attribute = key.split('/').pop();     let details = _.map(value, function(item) { return item['detail']; });      controls[attribute].seterrors({ remote: details.join(', ') });   }); } 

Comments

Popular posts from this blog

android - net_scheduler holding wakelock -

sql - MySQL : Getting Entries from a many-to-many table -

java - Retrieving data from database using jsp (Hibernate + Spring + Maven) -