Validate validates the variable configuration is well-formed.
()
| 269 | |
| 270 | // Validate validates the variable configuration is well-formed. |
| 271 | func (v *Variable) Validate() error { |
| 272 | if v == nil { |
| 273 | return errors.New("invalid variable: nil") |
| 274 | } |
| 275 | if v.Name == "" { |
| 276 | return errors.New("invalid variable: missing variable name") |
| 277 | } |
| 278 | if err := v.GetType().Validate(); err != nil { |
| 279 | return fmt.Errorf("invalid variable %q: %w", v.Name, err) |
| 280 | } |
| 281 | if v.GetType().IsTypeParam { |
| 282 | return fmt.Errorf("invalid variable %q: variables cannot be type parameters", v.Name) |
| 283 | } |
| 284 | return nil |
| 285 | } |
| 286 | |
| 287 | // GetType returns the variable type description. |
| 288 | // |
no test coverage detected