ValidateTemperatureParam validates the "temperature" parameter value (V-MAF-003). Must be a finite decimal float in [0.0, 2.0].
(value string)
| 50 | // ValidateTemperatureParam validates the "temperature" parameter value (V-MAF-003). |
| 51 | // Must be a finite decimal float in [0.0, 2.0]. |
| 52 | func ValidateTemperatureParam(value string) error { |
| 53 | f, err := strconv.ParseFloat(value, 64) |
| 54 | if err != nil { |
| 55 | return fmt.Errorf("model parameter 'temperature': value %q cannot be parsed as a decimal float (V-MAF-003)", value) |
| 56 | } |
| 57 | if math.IsNaN(f) || math.IsInf(f, 0) { |
| 58 | return fmt.Errorf("model parameter 'temperature': value %q is not a finite number (V-MAF-003)", value) |
| 59 | } |
| 60 | if f < 0.0 || f > 2.0 { |
| 61 | return fmt.Errorf("model parameter 'temperature': value %q is out of range; must be in [0.0, 2.0] (V-MAF-003)", value) |
| 62 | } |
| 63 | return nil |
| 64 | } |
| 65 | |
| 66 | // ValidateKnownParams validates the known parameters in a parsed identifier. |
| 67 | // Unknown parameters are tolerated (V-MAF-011 emits a warning, not an error). |