Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValidationConfig issue #14

Open
GonzaloCorchon opened this issue Dec 24, 2024 · 3 comments
Open

ValidationConfig issue #14

GonzaloCorchon opened this issue Dec 24, 2024 · 3 comments

Comments

@GonzaloCorchon
Copy link

I've been banging my head against the wall for a couple of hours trying to make this library work in Angular 19.
From what I've been able to research, there is an issue with "validationConfig" and the ngForm in the FormDirective class.
When you create the streams based on the validationConfig property, the very first time the ngForm does not have the inner controls yet configured so you get a console error. If you apply a setTimeout trick to set the validationConfig after a second, then it works as expected.

image

image

I've prepared a really simple Stackblitz demo so you can see it live
https://stackblitz.com/edit/stackblitz-starters-susmgnkx?file=src%2Fmain.ts

@lwestenberg
Copy link

having the same issue and was about to post an issue as well. The problem is in line 175 of https://github.com/simplifiedcourses/ngx-vest-forms/blob/master/projects/ngx-vest-forms/src/lib/directives/form.directive.ts
: this.ngForm?.form.get(key)?.valueChanges.

The stream is being created in the constructor but the control might not exist at this moment so it tries to subscribe on valueChanges and the end result is that an undefined value is being added to the streams and it tries to zip it.

@GonzaloCorchon as a temporary workaround you can set the validationConfig from ngAfterViewInit in your component so it's filtered initially in the pipe and added at a moment when the control exists.

@simplifiedcourses perhaps move the validationConfig code from the constructor to an ngAfterViewInit in the form.directive?

@the-ult
Copy link
Collaborator

the-ult commented Dec 24, 2024

After migrating to Angular 19, adding it to afterRender might be even better.

Gonna try to provide a PR in the coming week(s) with Angular 19.

But maybe a small bugfix until that time might be better.

@kevinmeyvaert
Copy link

I'm seeing a similar error here, still on Angular 18.2.7. Just to confirm @GonzaloCorchon, the validationConfig also doesn't work in your case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants