Derive independent glossary context and protection
This commit is contained in:
@@ -6,7 +6,6 @@ import (
|
||||
|
||||
"gitea.maximumdirect.net/eric/audita/v3/internal/core/modulecatalog"
|
||||
"gitea.maximumdirect.net/eric/audita/v3/internal/framework/contracts"
|
||||
"gitea.maximumdirect.net/eric/audita/v3/internal/validators/protected_terms"
|
||||
)
|
||||
|
||||
var builtInChains = map[string][]string{
|
||||
@@ -75,16 +74,6 @@ func ResolveBuiltInChain(moduleKey string, registry *Registry) ([]contracts.Vali
|
||||
|
||||
out := make([]contracts.Validator, 0, len(keys))
|
||||
for _, key := range keys {
|
||||
if moduleKey == modulecatalog.KeyGlossary && key == KeyProtectedTerms {
|
||||
// Glossary stages preserve current stricter protection semantics while
|
||||
// reporting the stable protected_terms key.
|
||||
v, buildErr := protected_terms.NewGlossaryStage()
|
||||
if buildErr != nil {
|
||||
return nil, buildErr
|
||||
}
|
||||
out = append(out, v)
|
||||
continue
|
||||
}
|
||||
v, buildErr := registry.MustBuild(key)
|
||||
if buildErr != nil {
|
||||
return nil, buildErr
|
||||
|
||||
@@ -14,31 +14,10 @@ func New() (contracts.Validator, error) {
|
||||
return validatormetadata.Wrap(validator{}, validatormetadata.ExecutionClassDeterministic), nil
|
||||
}
|
||||
|
||||
func NewGlossaryStage() (contracts.Validator, error) {
|
||||
return validatormetadata.Wrap(validator{glossaryStage: true}, validatormetadata.ExecutionClassDeterministic), nil
|
||||
}
|
||||
type validator struct{}
|
||||
|
||||
type validator struct {
|
||||
glossaryStage bool
|
||||
}
|
||||
|
||||
func (v validator) Name() string {
|
||||
return Key
|
||||
}
|
||||
func (v validator) Name() string { return Key }
|
||||
|
||||
func (v validator) Validate(_ context.Context, req contracts.ValidationRequest) (frameworkvalidators.Result, error) {
|
||||
if !v.glossaryStage && req.ModuleKey == "glossary" {
|
||||
decisions := make([]frameworkvalidators.Decision, 0, len(req.CandidateProposal))
|
||||
for _, c := range req.CandidateProposal {
|
||||
decisions = append(decisions, frameworkvalidators.Decision{
|
||||
ProposalIndex: c.ProposalIndex,
|
||||
Approved: true,
|
||||
ReasonCode: frameworkvalidators.ReasonApproved,
|
||||
Message: "approved",
|
||||
})
|
||||
}
|
||||
return frameworkvalidators.Result{ValidatorName: Key, Decisions: decisions}, nil
|
||||
}
|
||||
|
||||
return frameworkvalidators.ValidateProtectedTerms(req, v.glossaryStage)
|
||||
return frameworkvalidators.ValidateProtectedTerms(req)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user