Skip to content
Snippets Groups Projects
Commit c6a4c8d0 authored by Daniel Naude's avatar Daniel Naude
Browse files

Refactor TradingHours struct and add validation for start and end times

parent 9feae7cf
Branches
Tags v1.209.0
No related merge requests found
......@@ -296,6 +296,9 @@ func (t *TradingHours) Validate() bool {
}
startHourMinSlice := strings.Split(day.StartTime, ":")
if len(startHourMinSlice) != 2 {
return false
}
startHour, startMin := startHourMinSlice[0], startHourMinSlice[1]
startHourInt, err := strconv.Atoi(startHour)
if err != nil || startHourInt < 0 || startHourInt > 23 {
......@@ -307,6 +310,9 @@ func (t *TradingHours) Validate() bool {
}
endHourMinSlice := strings.Split(day.EndTime, ":")
if len(endHourMinSlice) != 2 {
return false
}
endHour, endMin := endHourMinSlice[0], endHourMinSlice[1]
endHourInt, err := strconv.Atoi(endHour)
if err != nil || endHourInt < 0 || endHourInt > 23 {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment