Skip to content
Merged
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 @@ -124,7 +124,11 @@ function TransactionStartDateStep() {
value={startDate}
label={translate('iou.startDate')}
onInputChange={(value) => {
setErrorText('');
if (!isRequiredFulfilled(value)) {
setErrorText(translate('common.error.fieldRequired'));
} else {
setErrorText('');
}
setStartDate(value);
}}
Comment on lines 126 to 133

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Issue: Inconsistent validation logic with submit function

There's a logical inconsistency between this validation and the submit function:

  1. Line 53 uses isRequiredFulfilled(startDate) to validate
  2. Line 127 uses !value to validate

The isRequiredFulfilled function likely checks for more than just falsy values (e.g., it may trim whitespace). This means:

  • A user could enter whitespace-only input and not see an error in the input handler
  • But they would get an error on submit

Recommendation:

Suggested change
onInputChange={(value) => {
setErrorText('');
if (!value) {
setErrorText(translate('common.error.fieldRequired'));
} else {
setErrorText('');
}
setStartDate(value);
}}
onInputChange={(value) => {
if (!isRequiredFulfilled(value)) {
setErrorText(translate('common.error.fieldRequired'));
} else {
setErrorText('');
}
setStartDate(value);
}}

This ensures validation is consistent throughout the component.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's address this as I also mentioned it in my review

minDate={CONST.CALENDAR_PICKER.MIN_DATE}
Expand Down
Loading