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

The validators are not triggered on value change and init #86

Closed
C0ZEN opened this issue Apr 20, 2021 · 6 comments
Closed

The validators are not triggered on value change and init #86

C0ZEN opened this issue Apr 20, 2021 · 6 comments

Comments

@C0ZEN
Copy link
Contributor

C0ZEN commented Apr 20, 2021

Context

In one of my project, I performed the migration from Angular 9 to 10.
I saw some failing tests related to the forms validation.
I figured that using this project was the root cause.
Using Angular imports instead (for the FormGroup and FormControl) fixed my issue.

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:

Current behavior

The validators are not working (native and custom).

Expected behavior

An empty string value in a control with a required validator or a custom one (actually in this reproduction it was a validator that check if the value is null, undefined or '') should be considered as an error.

Minimal reproduction of the problem with instructions

In this reproduction, there is two identical forms that should invalidate the form right from the initialisation.
One is based on classes from Angular and the second from ngneat.
Angular is working as expected.
Ngneat is telling me that my form is valid.
I can see that the custom validator log is not trigger when the value change in the ngneat form.

https://ngneat-testing-issue.stackblitz.io/
image

What is the motivation / use case for changing the behavior?

It should work like Angular.

Environment


Angular version: 11.0.8


Browser:
- [x] Chrome (desktop) version 89.0.4389.128
@NetanelBasal
Copy link
Member

Does the issue happen in any version above v9?

@C0ZEN
Copy link
Contributor Author

C0ZEN commented Apr 22, 2021

@NetanelBasal v9 was fine, v10 is failing, v11 (Stackblitz) is also failing :/

@NetanelBasal
Copy link
Member

@C0ZEN
Copy link
Contributor Author

C0ZEN commented Apr 22, 2021

@NetanelBasal I forked your sandbox and I was not able to reproduce the issue even after changing as much stuff as possible to reproduce the same environment than the Stackblitz reproduction one...
Do you have any clue to help me solve this? Thanks!

@NetanelBasal
Copy link
Member

Unfortunately not. We're simply extending the Angular FormControl. There is nothing special in the code.

Try to debug the code.

@C0ZEN
Copy link
Contributor Author

C0ZEN commented Apr 22, 2021

I ran the Stackblitz reproduction locally and there is no issue (so Stackblitz bye bye, lier).
I tested in my project the same code and it was fine as well.
The only remaining issue I have is from the original source of the error: the Jest tests.
I tested a lot of things and I was never able to have a test validating that the form is invalid as expected and at this point I give up.
Sorry for the false alarm, it seems that there is something in my project that just alter the behaviour in the specs and that's it, nothing to fear from this project.
Thank you for the feedbacks!

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

2 participants