Open 8lall0 opened 3 years ago
Got stuck on same problem. But there is a (dirty) solution:
Pristine
creates an object property on input
that you pass as addError
argument. That object has errors
array, or at least it should have, but it's not initialized.
Manually initialize errors
array before using addError
const a = form.querySelector('input[name="email"]');
if (a?.pristine?.errors === undefined) a.pristine.errors = [];
pristine.addError(a, "asd");
Thanks, it works!
I think that this is a bug that needs to be fixed by simply initialiting the errors array on creation.
Yeah, it definitely should be fixed "inside" Pristine, not like this, but for now it gets the job done 😄
const a = form.querySelector('input[name="email"]'); pristine.addError(a, 'asd');
It gives me:
How should i use addError()?
Thanks!