Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include min and max values in the validation message in a number question if the values are in the extension #2763

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

chungwwei
Copy link
Contributor

@chungwwei chungwwei commented Jan 1, 2025

IMPORTANT: All PRs must be linked to an issue (except for extremely trivial and straightforward changes).

Fixes #2757

Description
Show number must be between <INT_MIN> and <INT_MAX> when input is not an integer.
Use the max and min values in the extension if they are defined.

Alternative(s) considered
Have you considered any alternatives? And if so, why have you chosen the approach in this PR?

Type
Choose one: Bug fix

Screenshots (if applicable)
Screen_recording_20250101_225054.webm

Checklist

  • I have read and acknowledged the Code of conduct.
  • I have read the Contributing page.
  • I have signed the Google Individual CLA, or I am covered by my company's Corporate CLA.
  • I have discussed my proposed solution with code owners in the linked issue(s) and we have agreed upon the general approach.
  • I have run ./gradlew spotlessApply and ./gradlew spotlessCheck to check my code follows the style guide of this project.
  • I have run ./gradlew check and ./gradlew connectedCheck to test my changes locally.
  • I have built and run the demo app(s) to verify my change fixes the issue and/or does not break the demo app(s).

@chungwwei chungwwei requested a review from a team as a code owner January 1, 2025 03:06
@chungwwei chungwwei requested a review from MJ1998 January 1, 2025 03:06
Copy link
Collaborator

@FikriMilano FikriMilano left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

Comment on lines +94 to +99

val minValue =
(questionnaireViewItem.minAnswerValue as? IntegerType)?.value ?: Int.MIN_VALUE
val maxValue =
(questionnaireViewItem.maxAnswerValue as? IntegerType)?.value ?: Int.MAX_VALUE

Copy link
Collaborator

Choose a reason for hiding this comment

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

what happens when the minValue is bigger than the maxValue?
how about we throw an exception when that happens?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added the exception. UI will crash when minValue > maxValue, like the slider and date widgets.

Copy link
Collaborator

@jingtang10 jingtang10 left a comment

Choose a reason for hiding this comment

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

Thanks for adding this. I'm ok with this PR.

Fikri's point is a good one - we do throw exceptions in other widgets when min value > max value. But I'm a bit concerned about the UI crasing... I wonder if we actually should remove that exception from the date and slider widgets.

But I'm open-minded in this case. I'll approve this PR - but pls resolve the exception question with fikri - and we can then merge this pr.

Thanks again for this - good work!

@chungwwei chungwwei requested a review from FikriMilano January 17, 2025 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Number question validation message does not consider min max value given in the question
3 participants