Open metaturso opened 1 year ago
@metaturso Your custom errors will be removed on every calling of hasError function. You need to use survey.onSettingQuestionErrors event to add your custom error.
Thank you, Andrew
Marvellous. Thanks very much for the info, @andrewtelnov, that looks exactly like what I need.
Hi @andrewtelnov, I apologize for reopening this. Would you mind suggesting an alternative to survey.onSettingQuestionErrors that supports async validation?
I understand SurveyJS has technical limitations that prevent it from supporting async validation, which I had originally hoped could be worked around by deferring the call to hasErrors
until after the validation results had been attached to the question. Alas, as you pointed out, the errors are cleared from the question upon calling hasErrors
.
I've asked a friend to have a look at this and we both agree that onSettingQuestionErrors
isn't going to work. It can't be used to validate a question whose validation status is determined by an async call.
What do you suggest other than calling onServerValidateQuestions
which, as described in #5427, cannot be used in a scenarios that involve validating the survey without triggering the undesirable and unchangeable default "on complete" behaviour?
Are you requesting a feature, reporting a bug or asking a question?
This is a bug report.
What is the current behavior?
Calling
question.hasErrors()
after adding one or more errors by callingquestion.addErrors()
results in the custom errors being lost.All variants of
hasErrors()
are only aware of the SurveyJS errors produced by validators.What is the expected behavior?
My expectation is that calling
question.hasErrors()
,survey.hasPageErrors()
,survey.hasCurrentPageErrors()
, orsurvey.hasErrors()
should preserve custom errors manually added to a question by callingaddError()
.How would you reproduce the current behavior (if this is a bug)?
Obtain the instance of a SurveyJS question and call
addError()
before calling any of thehasErrors()
methods available.Provide the test code and the tested page URL (if applicable)
Tested page URL: https://codesandbox.io/s/frosty-grass-cipyl9?file=/src/App.vue
Test code
Specify your