This Commented CUE demonstrates constraining the sum of a list of numbers.

package example

import "list"

// both data fields are lists of numbers
good_list: [...number]
bad_list: [...number]

// We introduce a hidden CUE field for each list
// we want to check. Each hidden field unifies
// the relevant value constraint with the list's
// sum
_good_sum: <=100 & list.Sum(good_list)
_bad_sum:  <=99.5 & list.Sum(bad_list)
good_list: [ 1,2,3,4 ]
bad_list:  [ 1,2,3,100.5 ]
$ cue vet .:example data.yml
_bad_sum: invalid value 106.5 (out of bound <=99.5):