This Commented CUE demonstrates how to constrain fields to contain string representations of integer values.

package example

import "strconv"

// Constrain s1 and s2 to be the string
// interpolation of the result of converting
// their respective values to integers.
s1?: "\(strconv.Atoi(s1))"
s2?: "\(strconv.Atoi(s2))"
# s1 is a valid integer
s1: "137"

# s2 is not a valid integer
s2: "42.7"
$ cue vet .:example data.yml
s2: invalid interpolation: error in call to strconv.Atoi: strconv.Atoi: parsing "42.7": invalid syntax:

The constraint enforces that the concrete values of s1 and s2 are equal to the string-to-int-to-string conversions of those same values. This process must start and end with identical values, otherwise validation fails, as in the case of s2.