예제 #1
0
// ValidateStepInputOutputModel ...
func ValidateStepInputOutputModel(env envmanModels.EnvironmentItemModel, checkRequiredFields bool) error {
	if err := env.Validate(); err != nil {
		return err
	}

	if checkRequiredFields {
		options, err := env.GetOptions()
		if err != nil {
			return err
		}

		if options.Title == nil || *options.Title == "" {
			return errors.New("Invalid environment: missing or empty title")
		}
	}

	return nil
}
예제 #2
0
// ValidateStepInputOutputModel ...
func ValidateStepInputOutputModel(env envmanModels.EnvironmentItemModel, checkRequiredFields bool) error {
	key, _, err := env.GetKeyValuePair()
	if err != nil {
		return fmt.Errorf("Invalid environment (%s), err: %s", key, err)
	}

	if err := env.Validate(); err != nil {
		return fmt.Errorf("Invalid environment (%s), err: %s", key, err)
	}

	if checkRequiredFields {
		options, err := env.GetOptions()
		if err != nil {
			return fmt.Errorf("Invalid environment (%s), err: %s", key, err)
		}

		if options.Title == nil || *options.Title == "" {
			return fmt.Errorf("Invalid environment (%s), err: missing or empty title", key)
		}
	}

	return nil
}