validateRoleValues checks members independently; it does not check pairing.
(in scheduleRoles)
| 341 | |
| 342 | // validateRoleValues checks members independently; it does not check pairing. |
| 343 | func validateRoleValues(in scheduleRoles) error { |
| 344 | if in.DeadlineBehavior != nil && !oneOf(*in.DeadlineBehavior, []string{"lapses", "stays_owed"}) { |
| 345 | return fieldErr("deadline_behavior", "enum", "deadline_behavior must be lapses or stays_owed") |
| 346 | } |
| 347 | for _, n := range []*int{&in.TargetDays, &in.TargetSecs, in.EarliestDays, in.EarliestSecs, in.DeadlineDays, in.DeadlineSecs, in.OccupiedDays, in.OccupiedSecs} { |
| 348 | if n != nil && (int64(*n) < math.MinInt32 || int64(*n) > math.MaxInt32) { |
| 349 | return fieldErr("roles", "range", "a role offset is out of range") |
| 350 | } |
| 351 | } |
| 352 | if hasNUL(in.Outcome) { |
| 353 | return fieldErr("outcome", "enum", "outcome cannot contain a NUL") |
| 354 | } |
| 355 | return nil |
| 356 | } |
| 357 | |
| 358 | // occupiedEnd applies an offset using the schedule's own civil arithmetic. |
| 359 | // Validate it even when a deadline takes precedence over the window label. |
no test coverage detected