-
Notifications
You must be signed in to change notification settings - Fork 175
Open
Labels
Description
Hi huei90,
First of all, thanks to provide so useful validation module in angular world. I like it very much.
It's powerful to validate the form input, textarea and select control in client side, but it's only in client side.
In many cases, we want to provide a consolidated way to feed back the error messages from server side validation to the specific form controls, say, validate whether the userName is duplicated and show the "user name xxx is occupied" label beside the userName input. Since the validation is occurred on server side, we can't pre-define the errors in front-end rules. So if the module provide such a API
$validationProvider.showErrors(form, errors)It will be very helpful. Hence we can config the consolidated error/exception handling in angular config:
.config(['app', '$httpProvider', '$validationProvider', function (app, $httpProvider, $validationProvider){
$httpProvider.defaults.transformResponse.push(function (data, headersGetter) {
...
else if(data.code === 'VALIDATION_ERROR'){
var forms = app.$rootScope.forms || {};
var form = forms[headersGetter('x-form-id')];
$validationProvider.showErrors(form, data.fieldErrors);
}
...
}
}