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

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -