Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,14 @@ internal object EditTextDecimalViewHolderFactory :
)
// Update error message if draft answer present
if (questionnaireViewItem.draftAnswer != null) {
val minValue = questionnaireViewItem.minAnswerValue?.toString() ?: DecimalType(Int.MIN_VALUE).toString()
val maxValue = questionnaireViewItem.maxAnswerValue?.toString() ?: DecimalType(Int.MAX_VALUE).toString()
Comment on lines +79 to +80
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we check fhir spec about decimal. It was mentioned that the limit is 18 digit + 1 decimal point (https://build.fhir.org/datatypes.html#decimal)

So, I think we shouldn't use the max or min value of integer, as it only accepts 10 digits at most (https://build.fhir.org/datatypes.html#integer)

Also, if we check the parent class of DecimalType, it's actually BigDecimal. In Java BigDecimal doesn't really have a limit, it's constrained only by the amount of available memory.

But it's good to follow the limit set by fhir spec.

textInputLayout.error =
textInputLayout.context.getString(R.string.decimal_format_validation_error_msg)
textInputLayout.context.getString(
R.string.decimal_format_validation_error_msg,
minValue,
maxValue
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,13 @@ internal object EditTextIntegerViewHolderFactory :
)
// Update error message if draft answer present
if (questionnaireViewItem.draftAnswer != null) {
val minValue = questionnaireViewItem.minAnswerValue?.toString() ?: IntegerType(Int.MIN_VALUE).toString()
val maxValue = questionnaireViewItem.maxAnswerValue?.toString() ?: IntegerType(Int.MAX_VALUE).toString()
textInputLayout.error =
textInputLayout.context.getString(
R.string.integer_format_validation_error_msg,
formatInteger(Int.MIN_VALUE),
formatInteger(Int.MAX_VALUE),
minValue,
maxValue
)
}
}
Expand Down