@@ -217,6 +217,11 @@ func ValidateSpec(files []File, isTargetMandatory, isSearchBasedSpec bool) error
217217 isExplode , _ := file .IsExplode (false )
218218 isBypassArchiveInspection , _ := file .IsBypassArchiveInspection (false )
219219 isTransitive , _ := file .IsTransitive (false )
220+ isPackage := len (file .Package ) > 0
221+ isVersion := len (file .Version ) > 0
222+ isType := len (file .Type ) > 0
223+ isRepoKey := len (file .RepoKey ) > 0
224+
220225 if isPathMapping {
221226 if ! isAql {
222227 return errorutils .CheckErrorf ("pathMapping is supported only with aql" )
@@ -234,11 +239,9 @@ func ValidateSpec(files []File, isTargetMandatory, isSearchBasedSpec bool) error
234239 if ! isSearchBasedSpec && ! isPattern {
235240 return errorutils .CheckErrorf ("spec must include a pattern" )
236241 }
237- if isBuild && isBundle {
238- return fileSpecValidationError ("build" , "bundle" )
239- }
240- if isSearchBasedSpec && ! isAql && ! isPattern && ! isBuild && ! isBundle {
241- return errorutils .CheckErrorf ("spec must include either aql, pattern, build or bundle" )
242+
243+ if isSearchBasedSpec && ! isAql && ! isPattern && ! isBuild && ! isBundle && ! isPackage {
244+ return errorutils .CheckErrorf ("spec must include either aql, pattern, build, bundle or package" )
242245 }
243246 if isOffset {
244247 if isBuild {
@@ -259,9 +262,6 @@ func ValidateSpec(files []File, isTargetMandatory, isSearchBasedSpec bool) error
259262 return fileSpecValidationError ("bundle" , "limit" )
260263 }
261264 }
262- if isAql && isPattern {
263- return fileSpecValidationError ("aql" , "pattern" )
264- }
265265 if isAql && isExclusions {
266266 return fileSpecValidationError ("aql" , "exclusions" )
267267 }
@@ -295,6 +295,11 @@ func ValidateSpec(files []File, isTargetMandatory, isSearchBasedSpec bool) error
295295 if isBypassArchiveInspection && ! isExplode {
296296 return errorutils .CheckErrorf ("spec cannot include 'bypass-archive-inspection' if 'explode' is not included" )
297297 }
298+ if isPackage {
299+ if ! isVersion || ! isType || ! isRepoKey {
300+ return errorutils .CheckErrorf ("spec with type 'package' must include 'version', 'type' and 'repo_key'" )
301+ }
302+ }
298303 }
299304 return nil
300305}
0 commit comments