`validator` function isn't called when typing?
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 3.9k
- Forks
- 703
- PR merge metrics
- No merged PRs in 30d
Description
I want to restrict a field to use only alphabetic characters. I tried to configure my field like the following:
``` js
nga.field('service').validation({
required: true,
maxLength: 255,
validator: function(name) {
return !name.match(/^[A-Za-z]+$/g);
}
})
```
I may misunderstand how this validator works. I am expecting it to be called after each key, updating the field feedback icon. Yet, it seems to be called only when sending the form. And, even in this case, I have to throw an error, as returning `false` doesn't work.
``` js
nga.field('service').validation({
required: true,
maxLength: 255,
validator: function(name) {
if (!name.match(/^[A-Za-z]+$/g)) {
throw new Error('Service name should contain only alphabetic characters (no punctuation or numbers).');
}
}
})
```
But in this case, the feedback icon on the field is not updated.
Contributor guide
No contributing guide indexed for this repository
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 nga.field('service').validation(...) entry point and reproduce the alphabetic-only validator example. Trace when the validator runs and how the field feedback icon is updated; done means the validator behavior and feedback are consistent for typing and form submission.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angularjs, javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100