validateRoleValues checks members independently; it does not check pairing.
(in scheduleRoles)
| 310 | |
| 311 | // validateRoleValues checks members independently; it does not check pairing. |
| 312 | func validateRoleValues(in scheduleRoles) error { |
| 313 | if in.DeadlineBehavior != nil && !oneOf(*in.DeadlineBehavior, []string{"lapses", "stays_owed"}) { |
| 314 | return fieldErr("deadline_behavior", "enum", "deadline_behavior must be lapses or stays_owed") |
| 315 | } |
| 316 | for _, n := range []*int{&in.TargetDays, &in.TargetSecs, in.EarliestDays, in.EarliestSecs, in.DeadlineDays, in.DeadlineSecs, in.OccupiedDays, in.OccupiedSecs} { |
| 317 | if n != nil && (int64(*n) < math.MinInt32 || int64(*n) > math.MaxInt32) { |
| 318 | return fieldErr("roles", "range", "a role offset is out of range") |
| 319 | } |
| 320 | } |
| 321 | if hasNUL(in.Outcome) { |
| 322 | return fieldErr("outcome", "enum", "outcome cannot contain a NUL") |
| 323 | } |
| 324 | return nil |
| 325 | } |
| 326 | |
| 327 | // occupiedEnd applies an offset using the schedule's own civil arithmetic. |
| 328 | // Validate it even when a deadline takes precedence over the window label. |
no test coverage detected