angular-auto-validate
angular-auto-validate copied to clipboard
Passing a parameter from a Custom Validator directive to errorMessages doesn't work unless you make errorMessages dash-case.
It looks like the attribute on the input must match with dash-case for the "errorMessages" in the Error Message Resolver. Angular-auto-validate doesn't convert it to camel case even though the example for the "Error Message Resolver" documentation on the angular-auto-validate website shows it this way.
Using dash-case as the key for the "errorMessages" allows the value of "2" to be included where {0} is referenced in the errorMessages string.
The following works:
<input type="hidden" class="form-control" ng-model="cc.bundleData.items" min-required-items-in-bundle="2" />
errorMessages['min-required-items-in-bundle'] = 'Please include at least {0} items';
This doesn't work:
(The camel case for "anotherErrorMessage" won't work because it doesn't match the case of the attribute name on the input element which would be "another-error-message"):
errorMessages['anotherErrorMessage'] = 'An error message with the attribute value {0}';
Please update the code to support errorMessages with camel cases. Or update the documentation on the website for the "Error Message Resolver".
By the way this is a great module!
Issue is on line 814:
parameter = el.attr('data-ng-' + errorType) || el.attr(errorType);
If errorType is not snake case then jQuerys .attr method will not be able to find the attribute.