Question T9413
Visible to All Users

Question: does SCv2 supports custom validators different than expression?

created 3 years ago

Hi!

I had custom validator for custom phone input in v1. Now I found only solution described in docs.

It's not comfortable to migrate each phone question in all surveys and use complex expression syntax for my purposes.

Is there still any way to extend survey validators? If so, can You add the example?

Answers approved by surveyjs Support

created 3 years ago

Hello Boris,
SurveyJS Library is the same. We have developed a new Creator which is different from Creator V1. Both Creators V1 and V2 are working with the same version of SurveyJS Library.
The biggest change we did for library, we change packages. However, the current "survey-react" package is actually a bundle for "survey-core" and "survey-react-ui". The code is the same, packages are different. Creator V2 for react uses "survey-core" and "survey-react-ui", that is why it is better to use these packages if you are using Creator V2 for react.

Thank you,
Andrew
SurveyJS Team

    Show previous comments (1)

      Hello Boris,
      Here is the plunker example. Could you please fork it, add PhoneValidator class and put a link here?
      The error is in Creator V2 property grid. It is probably that we do not have your scenario in our tests. It means that we did not have this test in V1 as well, it is just work there.
      If the issue in Creator V2 then we will add a new unit test and fix it. We will need to reproduce it on our side first.

      Thank you,
      Andrew
      SurveyJS Team

        Hello, Andrew

        I created this plunker. Looks like it don't reproduce property grid problem. But it reproduce problem with missing working validator in validators list. I'll try to inspect my code and find what causing the problem and will update ticket later.

          Hello Boris,
          Please add the following line:

          JavaScript
          Survey.settings.supportedValidators.text.push("phone");

          Here is the updated example.
          We indeed changed it a little bit. Please look at our new settings property.

          Thank you,
          Andrew
          SurveyJS Team