@@ -225,46 +225,46 @@ export const KnowledgeForm: React.FunctionComponent<KnowledgeFormProps> = ({ kno
225
225
const contextStr = context . trim ( ) ;
226
226
if ( contextStr . length == 0 ) {
227
227
setDisableAction ( true ) ;
228
- return { errorMsg : 'Context is required' , context : ValidatedOptions . error } ;
228
+ return { msg : 'Context is required' , status : ValidatedOptions . error } ;
229
229
}
230
230
const tokens = contextStr . split ( / \s + / ) ;
231
231
if ( tokens . length > 0 && tokens . length <= 500 ) {
232
232
setDisableAction ( ! checkKnowledgeFormCompletion ( knowledgeFormData ) ) ;
233
- return { errorMsg : '' , context : ValidatedOptions . success } ;
233
+ return { msg : 'Valid Input ' , status : ValidatedOptions . success } ;
234
234
}
235
235
setDisableAction ( true ) ;
236
236
const errorMsg = 'Context must be less than 500 words. Current word count: ' + tokens . length ;
237
- return { errorMsg : errorMsg , context : ValidatedOptions . error } ;
237
+ return { msg : errorMsg , status : ValidatedOptions . error } ;
238
238
} ;
239
239
240
240
const validateQuestion = ( question : string ) => {
241
241
const questionStr = question . trim ( ) ;
242
242
if ( questionStr . length == 0 ) {
243
243
setDisableAction ( true ) ;
244
- return { errorMsg : 'Question is required' , context : ValidatedOptions . error } ;
244
+ return { msg : 'Question is required' , status : ValidatedOptions . error } ;
245
245
}
246
246
const tokens = questionStr . split ( / \s + / ) ;
247
247
if ( tokens . length > 0 && tokens . length < 250 ) {
248
248
setDisableAction ( ! checkKnowledgeFormCompletion ( knowledgeFormData ) ) ;
249
- return { errorMsg : '' , context : ValidatedOptions . success } ;
249
+ return { msg : 'Valid input ' , status : ValidatedOptions . success } ;
250
250
}
251
251
setDisableAction ( true ) ;
252
- return { errorMsg : 'Question must be less than 250 words. Current word count: ' + tokens . length , context : ValidatedOptions . error } ;
252
+ return { msg : 'Question must be less than 250 words. Current word count: ' + tokens . length , status : ValidatedOptions . error } ;
253
253
} ;
254
254
255
255
const validateAnswer = ( answer : string ) => {
256
256
const answerStr = answer . trim ( ) ;
257
257
if ( answerStr . length == 0 ) {
258
258
setDisableAction ( true ) ;
259
- return { errorMsg : 'Answer is required' , context : ValidatedOptions . error } ;
259
+ return { msg : 'Answer is required' , status : ValidatedOptions . error } ;
260
260
}
261
261
const tokens = answerStr . split ( / \s + / ) ;
262
262
if ( tokens . length > 0 && tokens . length < 250 ) {
263
263
setDisableAction ( ! checkKnowledgeFormCompletion ( knowledgeFormData ) ) ;
264
- return { errorMsg : '' , context : ValidatedOptions . success } ;
264
+ return { msg : 'Valid input ' , status : ValidatedOptions . success } ;
265
265
}
266
266
setDisableAction ( true ) ;
267
- return { errorMsg : 'Answer must be less than 250 words. Current word count: ' + tokens . length , context : ValidatedOptions . error } ;
267
+ return { msg : 'Answer must be less than 250 words. Current word count: ' + tokens . length , status : ValidatedOptions . error } ;
268
268
} ;
269
269
270
270
const handleContextInputChange = ( seedExampleIndex : number , contextValue : string ) : void => {
@@ -283,11 +283,11 @@ export const KnowledgeForm: React.FunctionComponent<KnowledgeFormProps> = ({ kno
283
283
const handleContextBlur = ( seedExampleIndex : number ) : void => {
284
284
const updatedSeedExamples = seedExamples . map ( ( seedExample : SeedExample , index : number ) : SeedExample => {
285
285
if ( index === seedExampleIndex ) {
286
- const { errorMsg , context } = validateContext ( seedExample . context ) ;
286
+ const { msg , status } = validateContext ( seedExample . context ) ;
287
287
return {
288
288
...seedExample ,
289
- isContextValid : context ,
290
- validationError : errorMsg
289
+ isContextValid : status ,
290
+ validationError : msg
291
291
} ;
292
292
}
293
293
return seedExample ;
@@ -323,11 +323,11 @@ export const KnowledgeForm: React.FunctionComponent<KnowledgeFormProps> = ({ kno
323
323
...seedExample ,
324
324
questionAndAnswers : seedExample . questionAndAnswers . map ( ( questionAndAnswerPair : QuestionAndAnswerPair , index : number ) => {
325
325
if ( index === questionAndAnswerIndex ) {
326
- const { errorMsg , context } = validateQuestion ( questionAndAnswerPair . question ) ;
326
+ const { msg , status } = validateQuestion ( questionAndAnswerPair . question ) ;
327
327
return {
328
328
...questionAndAnswerPair ,
329
- isQuestionValid : context ,
330
- questionValidationError : errorMsg
329
+ isQuestionValid : status ,
330
+ questionValidationError : msg
331
331
} ;
332
332
}
333
333
return questionAndAnswerPair ;
@@ -366,11 +366,11 @@ export const KnowledgeForm: React.FunctionComponent<KnowledgeFormProps> = ({ kno
366
366
...seedExample ,
367
367
questionAndAnswers : seedExample . questionAndAnswers . map ( ( questionAndAnswerPair : QuestionAndAnswerPair , index : number ) => {
368
368
if ( index === questionAndAnswerIndex ) {
369
- const { errorMsg , context } = validateAnswer ( questionAndAnswerPair . answer ) ;
369
+ const { msg , status } = validateAnswer ( questionAndAnswerPair . answer ) ;
370
370
return {
371
371
...questionAndAnswerPair ,
372
- isAnswerValid : context ,
373
- answerValidationError : errorMsg
372
+ isAnswerValid : status ,
373
+ answerValidationError : msg
374
374
} ;
375
375
}
376
376
return questionAndAnswerPair ;
0 commit comments