move a value range check to the place before the value is used

parent 451a6031
Pipeline #14411 failed with stages
in 53 minutes and 9 seconds