Knockout-Contrib / Knockout-Contrib/Knockout-Validation

validation may not work when relying only on parseInputAttributes

Open
#520 0 comments 0 reactions 0 assignees View on GitHub
bug help wanted
Dominant language
JavaScript
Stars
1k
Forks
366
PR merge metrics
No merged PRs in 30d

Description

When `parseInputAttributes: true` and the observable is not validatable the `input` does not get a validation message inserted, nor the validation class `validationElement`.

The problem is in the `validationCore` binding as it asynchronously executes `parseInputValidationAttributes`. The later method will make the observable validatable if it matches some criteria (eg. input type is number/email, has a required attribute etc.)

Solutions:
- execute `parseInputValidationAttributes` synchronously - this adds some overhead when bindings are applied.
- _duplicate_ code in the `validationCore` binding to ensure `config.insertMessages` and `config.decorateInputElement` are applied if the observable becomes validatable.

I've created a fiddle for this - it has both the solutions and some intructions on how to fix it. The interesting code starts at line 1016 in the JavaScript panel of JSFiddle.

http://jsfiddle.net/3594jm1o/

Any thoughts?

Contributor guide

Open the contributing guide

Research direction

Start with the validationCore binding and the code beginning around line 1016 in the linked JSFiddle. Trace how asynchronous parseInputValidationAttributes affects observables that become validatable when parseInputAttributes is enabled. Done means the input receives both the validation message and validationElement class in that scenario, with the chosen approach verified against the fiddle instructions.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.