From 6f20922831c167d91799da8cf893aed8ee8bba2b Mon Sep 17 00:00:00 2001 From: Kar Rui Lau Date: Thu, 2 May 2024 12:18:43 +0800 Subject: [PATCH] fix: backend type errors after upgrading typescript --- src/app/models/field/tableField.ts | 2 +- src/app/utils/field-validation/validators/tableValidator.ts | 2 +- src/app/utils/field-validation/validators/textValidator.ts | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/app/models/field/tableField.ts b/src/app/models/field/tableField.ts index 53309c6d32..35fb1f7797 100644 --- a/src/app/models/field/tableField.ts +++ b/src/app/models/field/tableField.ts @@ -48,7 +48,7 @@ const createTableFieldSchema = () => { min: 2, validate: { validator: function (this: ITableFieldSchema, v?: number) { - return !v || v > this.minimumRows + return !v || v > (this.minimumRows || 0) }, message: 'Maximum number of rows must be greater than minimum.', }, diff --git a/src/app/utils/field-validation/validators/tableValidator.ts b/src/app/utils/field-validation/validators/tableValidator.ts index 644a782a26..0ccdd4ac0f 100644 --- a/src/app/utils/field-validation/validators/tableValidator.ts +++ b/src/app/utils/field-validation/validators/tableValidator.ts @@ -30,7 +30,7 @@ const makeMinimumRowsValidator: TableValidatorConstructor = const { answerArray } = response const { minimumRows } = tableField - return answerArray.length >= minimumRows + return answerArray.length >= (minimumRows || 0) ? right(response) : left(`TableValidator:\tanswer has less than the minimum number of rows`) } diff --git a/src/app/utils/field-validation/validators/textValidator.ts b/src/app/utils/field-validation/validators/textValidator.ts index c547b8c1b7..69e9111283 100644 --- a/src/app/utils/field-validation/validators/textValidator.ts +++ b/src/app/utils/field-validation/validators/textValidator.ts @@ -26,7 +26,7 @@ const minLengthValidator: TextFieldValidatorConstructor = (textField) => (response) => { const { customVal: min } = textField.ValidationOptions if (min === null) return right(response) - return response.answer.length >= min + return response.answer.length >= (min || 0) ? right(response) : left(`TextValidator.minLength:\tanswer is less than minimum of ${min}`) } @@ -39,7 +39,7 @@ const maxLengthValidator: TextFieldValidatorConstructor = (textField) => (response) => { const { customVal: max } = textField.ValidationOptions if (max === null) return right(response) - return response.answer.length <= max + return response.answer.length <= (max || 0) ? right(response) : left( `TextValidator.maxLength:\tanswer is greater than maximum of ${max}`,