/*
Copyright 2025 vLLM Semantic Router.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package selection

import (
	"errors"
	"fmt"
	"strings"
)

var (
	ErrSelectionContextRequired  = errors.New("selection context is required")
	ErrCandidateModelsRequired   = errors.New("no candidate models provided")
	ErrCandidateModelNameMissing = errors.New("candidate model name is required")
)

// ValidateSelectionContext checks the common public selector input contract.
func ValidateSelectionContext(selCtx *SelectionContext) error {
	if selCtx == nil {
		return ErrSelectionContextRequired
	}
	if len(selCtx.CandidateModels) == 0 {
		return ErrCandidateModelsRequired
	}
	for i, modelRef := range selCtx.CandidateModels {
		if strings.TrimSpace(modelRef.Model) == "" {
			return fmt.Errorf("%w: candidate_models[%d]", ErrCandidateModelNameMissing, i)
		}
	}
	return nil
}
