Related page: Input
In order to get errors
or hints
reflected in the UI, non-mutable array operators should be used.
push()
, splice()
and pop()
won't change the UI because it won't change the array reference, you would need to use map()
, filter()
and spread operator ...
instead.
Please follow the guide below.
To add an error to an existing errors
myInput.errors = [...myInput.errors, 'This field is required'];
To add multiple errors
initially.
myInput.errors = ['This field is required', 'Minimum 3 characters are needed'];
To remove an error
myInput.errors = myInput.errors.filter((error) => error !== 'This field is required');
To remove all errors
myInput.errors = [];