Preserve selected collections in materialized references
This commit is contained in:
@@ -1,6 +1,31 @@
|
||||
package shared
|
||||
|
||||
import "gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
|
||||
)
|
||||
|
||||
// ValidateReferenceSelections rejects collection metadata on non-glossary inputs.
|
||||
func ValidateReferenceSelections(references contracts.ReferenceSet) error {
|
||||
names := make([]string, 0, len(references.Slots))
|
||||
for name := range references.Slots {
|
||||
names = append(names, name)
|
||||
}
|
||||
sort.Strings(names)
|
||||
for _, name := range names {
|
||||
if name == "glossary" || name == "spell_catalog" {
|
||||
continue
|
||||
}
|
||||
for _, item := range references.Slots[name].Items {
|
||||
if item.Collections != nil {
|
||||
return fmt.Errorf("reference slot %q does not support collection selection", name)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type ReferenceSlotDescriptions struct {
|
||||
Glossary string
|
||||
|
||||
Reference in New Issue
Block a user