Skip to content

Commit 9635c8b

Browse files
authored
fix: switch name and uri in Organisation checks (#271)
Fix the checks on Organisation objects, it was flipped: `uri` is the one being mandatory.
1 parent ab083a0 commit 9635c8b

8 files changed

Lines changed: 123 additions & 13 deletions

parser_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -306,10 +306,10 @@ func TestInvalidTestcasesV0(t *testing.T) {
306306
},
307307
"organisation_wrong_type.yml": ValidationResults{
308308
ValidationError{"organisation.name", "wrong type for this field", 18, 1},
309-
ValidationError{"organisation.name", "name is a required field", 18, 3},
309+
ValidationError{"organisation.uri", "uri is a required field", 18, 3},
310310
},
311-
"organisation_name_missing.yml": ValidationResults{
312-
ValidationError{"organisation.name", "name is a required field", 17, 3},
311+
"organisation_uri_missing.yml": ValidationResults{
312+
ValidationError{"organisation.uri", "uri is a required field", 18, 3},
313313
},
314314
"organisation_uri_wrong_italian_pa.yml": ValidationResults{
315315
ValidationError{"organisation.uri", "uri is not a valid URI", 20, 3},
@@ -360,8 +360,8 @@ func TestInvalidTestcasesV0(t *testing.T) {
360360
"fundedBy_wrong_type.yml": ValidationResults{
361361
ValidationError{"fundedBy.name", "wrong type for this field", 18, 1},
362362
},
363-
"fundedBy_name_missing.yml": ValidationResults{
364-
ValidationError{"fundedBy[0].name", "name is a required field", 0, 0},
363+
"fundedBy_uri_missing.yml": ValidationResults{
364+
ValidationError{"fundedBy[0].uri", "uri is a required field", 0, 0},
365365
},
366366
"fundedBy_uri_wrong_italian_pa.yml": ValidationResults{
367367
ValidationError{"fundedBy[0].uri", "uri is not a valid URI", 0, 0},
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
publiccodeYmlVersion: "0"
2+
3+
name: Medusa
4+
url: "https://github.com/italia/developers.italia.it.git"
5+
6+
platforms:
7+
- web
8+
9+
categories:
10+
- cloud-management
11+
12+
developmentStatus: development
13+
14+
softwareType: "standalone/other"
15+
16+
fundedBy:
17+
# Should NOT validate: uri is missing
18+
- name: foobar
19+
# uri:
20+
21+
description:
22+
en-GB:
23+
localisedName: Medusa
24+
shortDescription: >
25+
A rather short description which
26+
is probably useless
27+
longDescription: >
28+
Very long description of this software, also split
29+
on multiple rows. You should note what the software
30+
is and why one should need it. This is 158 characters.
31+
Very long description of this software, also split
32+
on multiple rows. You should note what the software
33+
is and why one should need it. This is 316 characters.
34+
Very long description of this software, also split
35+
on multiple rows. You should note what the software
36+
is and why one should need it. This is 474 characters.
37+
Very long description of this software, also split
38+
on multiple rows. You should note what the software
39+
is and why one should need it. This is 632 characters.
40+
features:
41+
- Just one feature
42+
43+
legal:
44+
license: AGPL-3.0-or-later
45+
46+
maintenance:
47+
type: "community"
48+
49+
contacts:
50+
- name: Francesco Rossi
51+
52+
localisation:
53+
localisationReady: true
54+
availableLanguages:
55+
- en
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
publiccodeYmlVersion: "0"
2+
3+
name: Medusa
4+
url: "https://github.com/italia/developers.italia.it.git"
5+
6+
platforms:
7+
- web
8+
9+
categories:
10+
- cloud-management
11+
12+
developmentStatus: development
13+
14+
softwareType: "standalone/other"
15+
16+
organisation:
17+
# Should NOT validate: uri is missing
18+
name: foobar
19+
# uri: "https://example.org"
20+
21+
description:
22+
en-GB:
23+
localisedName: Medusa
24+
shortDescription: >
25+
A rather short description which
26+
is probably useless
27+
longDescription: >
28+
Very long description of this software, also split
29+
on multiple rows. You should note what the software
30+
is and why one should need it. This is 158 characters.
31+
Very long description of this software, also split
32+
on multiple rows. You should note what the software
33+
is and why one should need it. This is 316 characters.
34+
Very long description of this software, also split
35+
on multiple rows. You should note what the software
36+
is and why one should need it. This is 474 characters.
37+
Very long description of this software, also split
38+
on multiple rows. You should note what the software
39+
is and why one should need it. This is 632 characters.
40+
features:
41+
- Just one feature
42+
43+
legal:
44+
license: AGPL-3.0-or-later
45+
46+
maintenance:
47+
type: "community"
48+
49+
contacts:
50+
- name: Francesco Rossi
51+
52+
localisation:
53+
localisationReady: true
54+
availableLanguages:
55+
- en

testdata/v0/invalid/fundedBy_name_missing.yml renamed to testdata/v0/valid/fundedBy_name_missing.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ softwareType: "standalone/other"
1515

1616
fundedBy:
1717
- uri: "https://example.org"
18-
# Should NOT validate: name is missing
18+
# Should validate: name is optional
1919
# name: foobar
2020

2121
description:

testdata/v0/invalid/organisation_name_missing.yml renamed to testdata/v0/valid/organisation_name_missing.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ softwareType: "standalone/other"
1515

1616
organisation:
1717
uri: "https://example.org"
18-
# Should NOT validate: name is missing
18+
# Should validate: name is optional
1919
# name: foobar
2020

2121
description:

testdata/v0/valid/valid_with_fundedBy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ developmentStatus: development
1414
softwareType: "standalone/other"
1515

1616
fundedBy:
17-
- name: foobar
17+
- uri: http://example.org/my-organisation
1818

1919
description:
2020
en-GB:

testdata/v0/valid/valid_with_organisation.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ developmentStatus: development
1414
softwareType: "standalone/other"
1515

1616
organisation:
17-
name: foobar
17+
uri: urn:x-custom:id
1818

1919
description:
2020
en-GB:

v0.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ type PublicCodeV0 struct {
2121
MonochromeLogo *string `json:"monochromeLogo,omitempty" yaml:"monochromeLogo,omitempty"`
2222

2323
Organisation *struct {
24-
Name string `json:"name" validate:"required" yaml:"name"`
25-
URI *string `json:"uri,omitempty" validate:"omitempty,organisation_uri" yaml:"uri,omitempty"`
24+
Name *string `json:"name,omitempty" yaml:"name,omitempty"`
25+
URI string `json:"uri" validate:"required,organisation_uri" yaml:"uri"`
2626
} `json:"organisation,omitempty" yaml:"organisation,omitempty"`
2727

2828
InputTypes *[]string `json:"inputTypes,omitempty" validate:"omitempty,dive,is_mime_type" yaml:"inputTypes,omitempty"`
@@ -35,8 +35,8 @@ type PublicCodeV0 struct {
3535
UsedBy *[]string `json:"usedBy,omitempty" yaml:"usedBy,omitempty"`
3636

3737
FundedBy *[]struct {
38-
Name string `json:"name" validate:"required" yaml:"name"`
39-
URI *string `json:"uri,omitempty" validate:"omitempty,organisation_uri" yaml:"uri,omitempty"`
38+
Name *string `json:"name,omitempty" yaml:"name,omitempty"`
39+
URI string `json:"uri" validate:"required,organisation_uri" yaml:"uri"`
4040
} `json:"fundedBy,omitempty" validate:"omitempty,dive" yaml:"fundedBy,omitempty"`
4141

4242
Roadmap *URL `json:"roadmap,omitempty" validate:"omitnil,url_http_url" yaml:"roadmap,omitempty"`

0 commit comments

Comments
 (0)