MCPcopy Create free account
hub / github.com/PerpetualSoftware/pad / validateRoleValues

Function validateRoleValues

internal/store/commitment.go:312–325  ·  view source on GitHub ↗

validateRoleValues checks members independently; it does not check pairing.

(in scheduleRoles)

Source from the content-addressed store, hash-verified

310
311// validateRoleValues checks members independently; it does not check pairing.
312func 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.

Callers 2

rolesFromInputFunction · 0.85
validateRolesPatchFunction · 0.85

Calls 3

oneOfFunction · 0.85
fieldErrFunction · 0.85
hasNULFunction · 0.85

Tested by

no test coverage detected