Finish the D&D module cleanup
This commit is contained in:
@@ -45,7 +45,7 @@ func (v *Validator) CheckpointFingerprints() []pipeline.CheckpointFingerprint {
|
||||
}
|
||||
|
||||
func (v *Validator) Validate(_ context.Context, req contracts.TypedValidationRequest[dnd.SceneDescriptionList]) (contracts.ValidationResult, error) {
|
||||
if shape.Validate(req.Value) != nil || !sourceRefsValid(req.Source, req.Value) {
|
||||
if shape.Validate(req.Value) != nil {
|
||||
return contracts.ValidationResult{Approved: true}, nil
|
||||
}
|
||||
resolver, err := shared.NewCitationResolver(req.Source)
|
||||
@@ -72,15 +72,6 @@ func (v *Validator) Validate(_ context.Context, req contracts.TypedValidationReq
|
||||
}, nil
|
||||
}
|
||||
|
||||
func sourceRefsValid(doc *source.SourceDocument, value dnd.SceneDescriptionList) bool {
|
||||
for _, scene := range value.Scenes {
|
||||
if source.ValidateRef(doc, scene.SourceRef) != nil {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func tokenSet(value string) map[string]struct{} {
|
||||
tokens := make(map[string]struct{})
|
||||
for _, token := range shared.NormalizedTokens(value) {
|
||||
|
||||
@@ -54,6 +54,14 @@ func TestValidatorUsesTranscriptOnlyAndDefersInvalidInputs(t *testing.T) {
|
||||
if err != nil || !malformed.Approved || len(malformed.Warnings) != 0 {
|
||||
t.Fatalf("malformed Validate() = %#v, %v; want deferral", malformed, err)
|
||||
}
|
||||
|
||||
invalidScene := scene("invalid", "Greencloak", "Greencloak arrives.")
|
||||
invalidScene.SourceRef.StartUnitID = 99
|
||||
invalidSource := dnd.SceneDescriptionList{Scenes: []dnd.SceneDescription{invalidScene}}
|
||||
deferred, err := New(Options{}).Validate(context.Background(), contracts.TypedValidationRequest[dnd.SceneDescriptionList]{Source: doc, Value: invalidSource})
|
||||
if err != nil || !deferred.Approved || len(deferred.Warnings) != 0 {
|
||||
t.Fatalf("invalid-source Validate() = %#v, %v; want deferral", deferred, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidatorRegistrationAndPolicyFingerprint(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user