Skip to content

Commit

Permalink
Fix validator (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
unanoc authored Nov 24, 2021
1 parent 3c536bb commit f7da40b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
24 changes: 24 additions & 0 deletions pkg/validation/folders.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,30 @@ OutLoop:
return nil
}

func ValidateFilesNotInList(files []fs.DirEntry, fileList []string) error {
compErr := NewErrComposite()

for _, dir := range files {
var found bool
for _, f := range fileList {
if dir.Name() == f {
found = true
break
}
}

if !found {
compErr.Append(fmt.Errorf("%w: %s", ErrMissingFile, dir.Name()))
}
}

if compErr.Len() > 0 {
return compErr
}

return nil
}

func ValidateAllowedFiles(files []fs.DirEntry, allowedFiles []string) error {
compErr := NewErrComposite()
for _, f := range files {
Expand Down
2 changes: 1 addition & 1 deletion src/validator/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ func (s *Service) ValidateValidatorsListFile(file *file.AssetFile) error {
return err
}

err = validation.ValidateHasFiles(dirAssetFolderFiles, listIDs)
err = validation.ValidateFilesNotInList(dirAssetFolderFiles, listIDs)
if err != nil {
return err
}
Expand Down

0 comments on commit f7da40b

Please sign in to comment.