Skip to content

Commit

Permalink
fix: backend type errors after upgrading typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
karrui committed May 2, 2024
1 parent 140e07c commit 6f20922
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/app/models/field/tableField.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/utils/field-validation/validators/textValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
}
Expand All @@ -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}`,
Expand Down

0 comments on commit 6f20922

Please sign in to comment.