code: func (v *Variable) ValidateTypeAndDefault() error {
  	// If an explicit type is declared, ensure it is valid
  	if v.DeclaredType != "" {
  		if _, ok := typeStringMap[v.DeclaredType]; !ok {
  			validTypes := []string{}
  			for k := range typeStringMap {
  				validTypes = append(validTypes, k)
  			}
  			return fmt.Errorf(
  				"Variable '%s' type must be one of [%s] - '%s' is not a valid type",
  				v.Name,
  				strings.Join(validTypes, ", "),
  				v.DeclaredType,
  			)
  		}
  	}
  
  	if v.DeclaredType == "" || v.Default == nil {
  		return nil
  	}
  
  	if v.inferTypeFromDefault() != v.Type() {
  		return fmt.Errorf("'%s' has a default value which is not of type '%s' (got '%s')",
  			v.Name, v.DeclaredType, v.inferTypeFromDefault().Printable())
  	}
  
  	return nil
  }
docs: // ValidateTypeAndDefault ensures that default variable value is compatible
  // with the declared type (if one exists), and that the type is one which is
  // known to Terraform