// Package sourcerange validates durable D&D source-reference ranges.
package sourcerange

import (
	"fmt"

	"gitea.maximumdirect.net/eric/notarius/internal/core/source"
)

// Validate checks the source-independent numeric constraints of a durable
// source reference. Source membership and extraction-chunk coverage require
// source context and remain the responsibility of source-aware validators.
func Validate(ref source.SourceRef) error {
	if ref.StartUnitID <= 0 {
		return fmt.Errorf("start_unit_id must be positive")
	}
	if ref.EndUnitID <= 0 {
		return fmt.Errorf("end_unit_id must be positive")
	}
	if ref.StartUnitID > ref.EndUnitID {
		return fmt.Errorf("start_unit_id must not exceed end_unit_id")
	}
	return nil
}
