Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,10 @@ func validateFieldsV0(publiccode PublicCode, parser *Parser, network bool, baseU
}

for i, v := range desc.Videos {
if v == nil {
continue
}

err := parser.checkOEmbedURL((*url.URL)(v))
if err != nil {
vr = append(vr, newValidationErrorf(
Expand Down Expand Up @@ -431,6 +435,10 @@ func validateFieldsV1(publiccode PublicCode, parser *Parser, network bool, baseU
}

for i, v := range desc.Videos {
if v == nil {
continue
}

err := parser.checkOEmbedURL((*url.URL)(v))
if err != nil {
vr = append(vr, newValidationErrorf(
Expand Down
4 changes: 4 additions & 0 deletions testdata/v0/invalid/description_en_videos_invalid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ description:
videos:
# Should NOT validate: not a valid URL
- ABC
# Should NOT validate: null is not a URL
-
# Should NOT validate: an empty string is not a URL
- ""

legal:
license: AGPL-3.0-or-later
Expand Down
4 changes: 4 additions & 0 deletions testdata/v1/invalid/description_en_videos_invalid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ description:
videos:
# Should NOT validate: not a valid URL
- ABC
# Should NOT validate: null is not a URL
-
# Should NOT validate: an empty string is not a URL
- ""

legal:
license: AGPL-3.0-or-later
Expand Down
2 changes: 1 addition & 1 deletion v0.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ type DescV0 struct {
APIDocumentation *URL `json:"apiDocumentation,omitempty" validate:"omitnil,url_http_url" yaml:"apiDocumentation,omitempty"`
Features *[]string `json:"features,omitempty" validate:"gt=0,dive" yaml:"features,omitempty"`
Screenshots []string `json:"screenshots,omitempty" yaml:"screenshots,omitempty"`
Videos []*URL `json:"videos,omitempty" validate:"dive,omitnil,url_http_url" yaml:"videos,omitempty"`
Videos []*URL `json:"videos,omitempty" validate:"dive,required,url_http_url" yaml:"videos,omitempty"`
Awards []string `json:"awards,omitempty" yaml:"awards,omitempty"`
}

Expand Down
3 changes: 3 additions & 0 deletions v0_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,11 @@ func TestInvalidTestcasesV0(t *testing.T) {
},
"description_en_videos_invalid.yml": ValidationResults{
ValidationError{"", "description.en.videos[0]", "videos[0] must be an HTTP URL", 41, 9},
ValidationError{"", "description.en.videos[1]", "videos[1] is a required field", 43, 8},
ValidationError{"", "description.en.videos[2]", "videos[2] must be an HTTP URL", 45, 9},
ValidationWarning{"", "description.en.videos", "This key is DEPRECATED and will be removed in the future. Link videos from the documentation or the website instead", 39, 5},
ValidationError{"", "description.en.videos[0]", "'ABC' is not a valid video URL supporting oEmbed: invalid oEmbed link: ABC", 41, 9},
ValidationError{"", "description.en.videos[2]", "'' is not a valid video URL supporting oEmbed: invalid oEmbed link: ", 45, 9},
},
"description_en_videos_invalid_oembed.yml": ValidationResults{
ValidationWarning{"", "description.en.videos", "This key is DEPRECATED and will be removed in the future. Link videos from the documentation or the website instead", 39, 5},
Expand Down
2 changes: 1 addition & 1 deletion v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ type DescV1 struct {
APIDocumentation *URL `json:"apiDocumentation,omitempty" validate:"omitnil,url_http_url" yaml:"apiDocumentation,omitempty"`
Features *[]string `json:"features,omitempty" validate:"gt=0,dive" yaml:"features,omitempty"`
Screenshots []string `json:"screenshots,omitempty" yaml:"screenshots,omitempty"`
Videos []*URL `json:"videos,omitempty" validate:"dive,omitnil,url_http_url" yaml:"videos,omitempty"`
Videos []*URL `json:"videos,omitempty" validate:"dive,required,url_http_url" yaml:"videos,omitempty"`
Awards []string `json:"awards,omitempty" yaml:"awards,omitempty"`
}

Expand Down
Loading