invalidValueError creates an error message with an optional suggestion for the closest valid value.
(field, value string, valid []string)
| 41 | |
| 42 | // invalidValueError creates an error message with an optional suggestion for the closest valid value. |
| 43 | func invalidValueError(field, value string, valid []string) error { |
| 44 | msg := fmt.Sprintf("invalid %s: %q (valid: %s)", field, value, strings.Join(valid, ", ")) |
| 45 | if suggestion := suggestValue(value, valid); suggestion != "" { |
| 46 | msg += fmt.Sprintf("; did you mean %q?", suggestion) |
| 47 | } |
| 48 | return fmt.Errorf("%s", msg) |
| 49 | } |
| 50 | |
| 51 | // validateSetEnums validates enum fields in the set command's UpdateRequest, providing suggestions on error. |
| 52 | func validateSetEnums(req taskfile.UpdateRequest) error { |