Skip to content

Commit

Permalink
Departure time can be equals to arrival time
Browse files Browse the repository at this point in the history
We consider just dates so these two could be equals (ofc)
  • Loading branch information
boozec committed May 24, 2024
1 parent b2a3496 commit 82d5160
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions internal/models/interest.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,17 @@ func ValidateInterest(db *gorm.DB, variables map[string]interface{}) (*InterestI
return nil, errors.New("`flight1`: `departure_airport` can't be equals to `arrival_airport`")
}

if in.Flight1DepartureTime.Equal(in.Flight1ArrivalTime) || in.Flight1DepartureTime.After(in.Flight1ArrivalTime) {
return nil, errors.New("`flight1`: `departure_time` can't be after or the same `arrival_time`")
if in.Flight1DepartureTime.After(in.Flight1ArrivalTime) {
return nil, errors.New("`flight1`: `departure_time` can't be after `arrival_time`")
}

if in.Flight2DepartureAirport != nil && in.Flight2DepartureTime != nil && in.Flight2ArrivalAirport != nil && in.Flight2ArrivalTime != nil {
if (*in.Flight2DepartureAirport) == (*in.Flight2ArrivalAirport) {
return nil, errors.New("`flight2`: `departure_airport` can't be equals to `arrival_airport`")
}

if (*in.Flight2DepartureTime).Equal(*in.Flight2ArrivalTime) || (*in.Flight2DepartureTime).After(*in.Flight2ArrivalTime) {
return nil, errors.New("`flight2`: `departure_time` can't be after or the same `arrival_time`")
if (*in.Flight2DepartureTime).After(*in.Flight2ArrivalTime) {
return nil, errors.New("`flight2`: `departure_time` can't be after `arrival_time`")
}
} else if !(in.Flight2DepartureAirport == nil || in.Flight2DepartureTime == nil || in.Flight2ArrivalAirport == nil || in.Flight2ArrivalTime == nil) {
return nil, errors.New("`flight2`: all fields must be nil or filled")
Expand Down

0 comments on commit 82d5160

Please sign in to comment.