Knockout-Contrib / Knockout-Contrib/Knockout-Validation
Adding contextual DOM information to returned observable information
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1k
- Forks
- 366
- PR merge metrics
- No merged PRs in 30d
Description
So, we're big fans of Knockout-Validation on our web app.
Normally, we just use inline validation, but we have a pretty beefy form that we want to enhance with some extra information (like an error summary, and showing where errors are on the page).
It would help to have contextual information about the error's validationElement. Something like this:
ko.bindingHandlers['validationElement'] = {
update: function (element, valueAccessor, allBindingsAccessor) {
...
obsv.validationElement = element;
With that change, you can then get this information out of the errors foreach loop:
validator.errors.forEach(function(item) {
if(!item.error()) {
return;
}
console.log(item.validationElement); // Returns dom node used as validationElement.
});
Would something like this be useful as a PR for other folks?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the validationElement binding handler shown in the issue and trace how its observable validation information is returned through validator.errors. Expose the validation element on each returned item, then verify that an errors foreach loop can read item.validationElement as the DOM node used for validation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100