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

Function validateRoleValues

internal/store/commitment.go:343–356  ·  view source on GitHub ↗

validateRoleValues checks members independently; it does not check pairing.

(in scheduleRoles)

Source from the content-addressed store, hash-verified

341
342// validateRoleValues checks members independently; it does not check pairing.
343func 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.

Callers 3

rolesFromInputFunction · 0.85
validateRolesPatchFunction · 0.85
planSeriesTargetTxMethod · 0.85

Calls 3

oneOfFunction · 0.85
fieldErrFunction · 0.85
hasNULFunction · 0.85

Tested by

no test coverage detected