To validate an entire observable all you should need to do is first tell the validation library that your vm is under validation by doing
and then you can simply call a .isValid() on your VM as such.
However, when doing this in Typescript I was getting the red squiggly as you see here.
At first I was not sure why, so I decided to take a peek at the source for the validation and I came across the code you see below.
How to fix this?
The simple solution that I found was to ‘fake’ Typescript into thinking that the .isValid computed is on my VM from the start. I did this by adding the following to my VM
Now you will notice that I am simply declaring the computed I am NO assigning it and that is ok. In fact if you look at the generated output from the Typescript compiler you will NOT see a computed created for .isValid(). But this does not matter. The Typescript compiler thinks it is there so you are free to use it off of your VM as you see here.
After adding my declaration for isValid() I was good to go and my code worked as expected both at code time and run time.
Till next time,