Knockout-Contrib / Knockout-Contrib/Knockout-Validation
Validation message computed based on the value of the field
- Dominant language
- JavaScript
- Stars
- 1k
- Forks
- 366
- PR merge metrics
- No merged PRs in 30d
Description
As I see it, you currently can compute a validation message based on parameters, by using the template system.
The problem I have is that you cannot do the same based on the value of the field.
Let say you have a select field that supports tagging and you want apply validation to each value. It would be nice to able to include the invalid values in the validation message.
select field : values
States : New York, Maine, Quebec, Montreal
Ex. Some values are invalid: Quebec, Montreal
This example is not the best since I would suggest states instead of allowing tagging, but the need is still there.
Actually, you can do this with async validation rules since you can return an object. like this :
```
return { isValid: false, message: 'Some values are invalid: Quebec, Montreal' };
```
Is it possible to do the same with normal (not async) validation?
Contributor guide
Research direction
Start by reading the normal validation path and its template system, then compare it with the async validation rules described in the issue. Determine how a normal rule could expose the field value to its message, and verify that tagging/select validation reports the invalid values while existing parameter-based messages remain supported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100