You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I wanted to validate the survey schema once received through my .NET API I've copied the reference code below. Is there a .NET flavour for this, if not I will create one.
import { Model } from "survey-core";
const surveyJson = { ... };
const survey = new Model(surveyJson);
survey.data = initialSurveyResultJson;
survey.clearIncorrectValues(true);
const correctSurveyResultJson = survey.data;
The text was updated successfully, but these errors were encountered:
@stephenstroud It would take several lines of code to do it in NodeJS and would require some coding for .Net (C#).
I would do the following.
Together with saving JSON definition that you get from Creator, I would store the data validation JSON with the following format: { questionName/questionValueName : { type: "string"/"number"/"date"/"Array"/..., isRequired: boolean }
So you will need to run through all your questions:
functiongetQuestionCodeType(q){if(q.getType()==="text"){if(q.inputType==="number")return"number";if(q.inputType==="date")return"date";}//Put more logic herereturn"string";}constdataValidationJSON={}creator.survey.getAllQuestions().forEach(q=>{dataValidationJSON[q.getValueName()]={type: getQuestionCodeType(q),isRequired: q.isRequired}});
Having this JSON on the server, you will be able to validate user responses .
You need it if you create a service where non authorized client can send the data to your service or from any client.
Hi, I wanted to validate the survey schema once received through my .NET API I've copied the reference code below. Is there a .NET flavour for this, if not I will create one.
The text was updated successfully, but these errors were encountered: