Comments (14)
Are you using an async validator?
from ng-bootstrap-form-validation.
Yes, obviously. If I remove this validator, all works. But this validation breaks form validation.
from ng-bootstrap-form-validation.
@ONbik-srebollo could you post a link to a code base or plunkr that reproduces your issue?
from ng-bootstrap-form-validation.
This is the field definition on FormGroup (with another fields):
this.formGroup = this.formBuilder.group({
'tin': [null, Validators.compose([Validators.required, tinValidator()]), this.asyncTinValidator.bind(this)],
});
And this my asyn validator.
asyncTinValidator(tinCtrl: FormControl): { [key: string]: any } {
return new Promise (resolve => {
return this.companyManager.checkTin(tinCtrl.value)
.then(result => {
return null;
}).catch(error => {
return { 'tin': { value: tinCtrl.value, message: error.error } };
});
});
}
tinValidator is a sync function that only validates format. This works perfectly, and this fails even if I remove all sync validators.
I would like to get a working example with this vendor, because I think this works (I've copied an example from official doc of Angular) but perhaps there is something wrong.
Thanks in advance for your patience.
from ng-bootstrap-form-validation.
@ONbik-srebollo @third774 we need to filter out any control.errors
that are null
instead of ValidationErrors
:
src/lib/Components/form-group-component/form-group-component.ts#87
- this.FormControlNames.filter(c => !c.valid)
+ this.FormControlNames.filter(c => !c.valid && !!c.errors)
This is the outcome with a 2 second async validation timeout:
from ng-bootstrap-form-validation.
What do y'all think of adding .has-warning
to the form group if an async validation is pending?
from ng-bootstrap-form-validation.
Hi @third774 .
I think it's not necessary, the validation is fast and it would be confusing to the user.
Thank you @kingcody !!!
from ng-bootstrap-form-validation.
I haven't done a lot of research, but do you know how we would determine if a field is pending an async validation?
from ng-bootstrap-form-validation.
Checking the status
property should do it.
https://angular.io/api/forms/AbstractControl
from ng-bootstrap-form-validation.
Be careful...
Now valid property is validated, that is the same as validate status !== valid. The PENDING status would be considered as error like now. I think is better @kingcody option to check if control has errors.
from ng-bootstrap-form-validation.
We're going to address the pending status in a separate issue.
from ng-bootstrap-form-validation.
I see that this will be fixed by #26 but it seems to be available on v3.
It's possible to be available on v2.2 ? I need it.
I'm trying to use it adding it to package.json:
"ng-bootstrap-form-validation": "^2.1.0-dev.20180130230430257Z.878bd2d1a9ab7c12256a15e87a9fb32458fd56b1",
But it isn't there. And I can't use dev-master, i don't know why (sorry, i'm a bit newbie).
Can you help me, please?
Thanks in advance.
from ng-bootstrap-form-validation.
@ONbik-srebollo try this:
npm install --save ng-bootstrap-form-validation@2.1.0-dev.20180130230430257Z.878bd2d1a9ab7c12256a15e87a9fb32458fd56b1
or
yarn add ng-bootstrap-form-validation@2.1.0-dev.20180130230430257Z.878bd2d1a9ab7c12256a15e87a9fb32458fd56b1
from ng-bootstrap-form-validation.
Thank you so much!!!!
I don't know what happened, but now has installed correctly. Async validation know works perfectly!!!
from ng-bootstrap-form-validation.
Related Issues (20)
- How disable multiple error messages
- how to incorporate debouncy behavior preventing double submit
- Issue with [formControl] input HOT 1
- How to apply to checkbox with custom error message
- License text not package in node_modules
- Project is dead?
- Ability to hide error messages inside <bfv-messages></bfv-messages> HOT 2
- [Question] ngx-translate support? HOT 3
- [Question] Don't show validation errors until first submit
- Support Angular 8 HOT 1
- [Feature Request] Surface error value in CustomErrorMessages array
- [Question] Example for server-side errors
- [Question] Disable validation for some fields HOT 1
- [QUESTION] How can i get requiredLength attribute of Validators.minLength when i format error message
- [Question] How to work with cross field validation HOT 1
- [Question] setErrors doesn't show messages.
- Support Angular 9 HOT 9
- Async validator don't call validSubmit function HOT 2
- Error message not showing when compiling with Ivy angular 9 HOT 3
- Custom error on form control with custom validator (AbstractControl, ValidatorFn)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ng-bootstrap-form-validation.