Description
WorkoutBuilder.validateSeconds can return true for invalid or negative time strings because it doesn't check for a failed parse (-1 sentinel).
File / Code
File: app/src/main/org/runnerup/workout/WorkoutBuilder.java
public static boolean validateSeconds(String newValue) {
long seconds = SafeParse.parseSeconds(newValue, -1);
long seconds2 = SafeParse.parseSeconds(DateUtils.formatElapsedTime(seconds), -1);
return seconds == seconds2;
}
Steps to Reproduce
- Call
WorkoutBuilder.validateSeconds("abc") or another invalid string.
- Observe that the method returns
true even though parsing fails.
Expected Behavior
Invalid or negative inputs should immediately return false.
Actual Behavior
The method formats and re-parses the invalid input, returning true.
Impact
Leads to false validation results, which could affect time-based workout configurations.
Proposed Fix
Add a guard clause before formatting and comparison:
if (seconds < 0) return false;