Parsley.js: Remove need for `addError`, `removeError`, ...
With the right set of feature, there shouldn’t be a need for addError
, updateError
and removeError
.
Others?
About this issue
- Original URL
- State: open
- Created 8 years ago
- Comments: 18 (2 by maintainers)
Commits related to this issue
- Hope that there's no need to manually handle errors [#1073] — committed to guillaumepotier/Parsley.js by marcandre 8 years ago
- Update doc for add/update/remove errors [#1073] [ci-skip] — committed to guillaumepotier/Parsley.js by marcandre 8 years ago
I’m using v2.3.11 and there appears to be no
addError()
method on the instance:$('#login-form').parsley().addError
isundefined
so I was wondering how do I manually activate errors now since callingwindow.ParsleyUI.addError
directs me to this issue.The docs seem to be out of date and still suggest using
window.ParsleyUI.addError
.My use case is that I use an API which does not have a possibility to AJAX check if the a field is valid. I only get errors after POSTing the entire form, e.g. if I submit a register form the API might respond with:
Which is a great response which I can easily traverse and map the error message to the proper fields, but I can not see how that is possible with the latest Parsley version.
This is a very simple example, but I’m dealing with very complex CMS forms which can return errors for multiple fields with no way to validate all the error types client-side before submit.
I could of course display bulk server messages or render them manually in each error container but I would love using Parsley for this since I’m already using it for client side validation.
I was convinced I tried it on field instance as well, but probably missed something. Anyway if someone else finds this thread like me here’s a little help on how to do it (at least until the docs get updated).
I agree with your point that the custom validators should replace the functions
addError
,updateError
andremoveError
, but with the current custom validators I am not able to implement it for all situations. For example:form:validated
.And maybe there are some more cases in which the custom validators cannot be used. If I need to explain things better, please let me know.
I am having another reason why I cannot use Custom Validators: My backend is not able to return Server Side Validation on a per field basis, but only for all fields. Therefore I am doing an ajax request to do the server side validation and then appending the errors to the different fields…