Skip to content

Commit 78b8bb0

Browse files
committed
feat: warn when a contact phone number is not in E.164 format
See publiccodeyml/publiccode.yml#348.
1 parent 084d6d7 commit 78b8bb0

12 files changed

Lines changed: 99 additions & 27 deletions

‎fields.go‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,21 @@ func validateFieldsV0(publiccode PublicCode, parser *Parser, network bool, baseU
129129
}
130130
}
131131

132+
if publiccodev0.Maintenance.Contacts != nil {
133+
for i, contact := range *publiccodev0.Maintenance.Contacts {
134+
if contact.Phone == nil || *contact.Phone == "" {
135+
continue
136+
}
137+
138+
if sharedValidate.Var(*contact.Phone, "e164") != nil {
139+
vr = append(vr, newValidationWarning(
140+
fmt.Sprintf("maintenance.contacts[%d].phone", i),
141+
"Phone numbers SHOULD use the E.164 format, e.g. '+3923113215112'",
142+
))
143+
}
144+
}
145+
}
146+
132147
if publiccodev0.Legal.AuthorsFile != nil {
133148
vr = append(vr, newValidationWarning(
134149
"legal.authorsFile",

‎testdata/v0/invalid/landingURL_invalid.yml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,15 @@ maintenance:
8080
- name: Francesco Rossi
8181
email: "francesco.rossi@comune.reggioemilia.it"
8282
affiliation: Comune di Reggio Emilia
83-
phone: +39 231 13215112
83+
phone: +3923113215112
8484
- name: Dario Bianchi
8585
email: "dario.bianchi@fornitore.it"
8686
affiliation: Fornitore Privato S.P.A.
87-
phone: +39 16 24231322
87+
phone: +391624231322
8888
- name: Giancarlo Verdi
8989
email: "dario.bianchi@fornitore.it"
9090
affiliation: Fornitore Privato S.P.A.
91-
phone: +39 16 24231322
91+
phone: +391624231322
9292

9393
localisation:
9494
localisationReady: true

‎testdata/v0/invalid/landingURL_wrong_type.yml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,15 @@ maintenance:
7676
- name: Francesco Rossi
7777
email: "francesco.rossi@comune.reggioemilia.it"
7878
affiliation: Comune di Reggio Emilia
79-
phone: +39 231 13215112
79+
phone: +3923113215112
8080
- name: Dario Bianchi
8181
email: "dario.bianchi@fornitore.it"
8282
affiliation: Fornitore Privato S.P.A.
83-
phone: +39 16 24231322
83+
phone: +391624231322
8484
- name: Giancarlo Verdi
8585
email: "dario.bianchi@fornitore.it"
8686
affiliation: Fornitore Privato S.P.A.
87-
phone: +39 16 24231322
87+
phone: +391624231322
8888

8989
localisation:
9090
localisationReady: true

‎testdata/v0/invalid/no-network/landingURL_invalid.yml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,15 @@ maintenance:
8080
- name: Francesco Rossi
8181
email: "francesco.rossi@comune.reggioemilia.it"
8282
affiliation: Comune di Reggio Emilia
83-
phone: +39 231 13215112
83+
phone: +3923113215112
8484
- name: Dario Bianchi
8585
email: "dario.bianchi@fornitore.it"
8686
affiliation: Fornitore Privato S.P.A.
87-
phone: +39 16 24231322
87+
phone: +391624231322
8888
- name: Giancarlo Verdi
8989
email: "dario.bianchi@fornitore.it"
9090
affiliation: Fornitore Privato S.P.A.
91-
phone: +39 16 24231322
91+
phone: +391624231322
9292

9393
localisation:
9494
localisationReady: true

‎testdata/v0/valid/no-network/valid.yml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,15 +181,15 @@ maintenance:
181181
- name: Francesco Rossi
182182
email: "francesco.rossi@example.org"
183183
affiliation: Comune di Reggio Emilia
184-
phone: +39 231 13215112
184+
phone: +3923113215112
185185
- name: Dario Bianchi
186186
email: "dario.bianchi@example.org"
187187
affiliation: Fornitore Privato S.P.A.
188-
phone: +39 16 24231322
188+
phone: +391624231322
189189
- name: Giancarlo Verdi
190190
email: "dario.bianchi@example.org"
191191
affiliation: Fornitore Privato S.P.A.
192-
phone: +39 16 24231322
192+
phone: +391624231322
193193

194194
localisation:
195195
localisationReady: true

‎testdata/v0/valid/valid.yml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,15 +184,15 @@ maintenance:
184184
- name: Francesco Rossi
185185
email: "francesco.rossi@example.org"
186186
affiliation: Comune di Reggio Emilia
187-
phone: +39 231 13215112
187+
phone: +3923113215112
188188
- name: Dario Bianchi
189189
email: "dario.bianchi@example.org"
190190
affiliation: Fornitore Privato S.P.A.
191-
phone: +39 16 24231322
191+
phone: +391624231322
192192
- name: Giancarlo Verdi
193193
email: "dario.bianchi@example.org"
194194
affiliation: Fornitore Privato S.P.A.
195-
phone: +39 16 24231322
195+
phone: +391624231322
196196

197197
localisation:
198198
localisationReady: true
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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+
description:
17+
en-GB:
18+
localisedName: Medusa
19+
shortDescription: >
20+
A rather short description which
21+
is probably useless
22+
longDescription: >
23+
Very long description of this software, also split
24+
on multiple rows. You should note what the software
25+
is and why one should need it. This is 158 characters.
26+
Very long description of this software, also split
27+
on multiple rows. You should note what the software
28+
is and why one should need it. This is 316 characters.
29+
Very long description of this software, also split
30+
on multiple rows. You should note what the software
31+
is and why one should need it. This is 474 characters.
32+
Very long description of this software, also split
33+
on multiple rows. You should note what the software
34+
is and why one should need it. This is 632 characters.
35+
features:
36+
- Just one feature
37+
38+
legal:
39+
license: AGPL-3.0-or-later
40+
41+
maintenance:
42+
type: "community"
43+
44+
contacts:
45+
- name: Francesco Rossi
46+
phone: "+39 231 13215112"
47+
48+
localisation:
49+
localisationReady: true
50+
availableLanguages:
51+
- en

‎testdata/v0/valid_with_warnings/valid_with_IT_riuso_codiceIPA.yml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,15 @@ maintenance:
7171
- name: Francesco Rossi
7272
email: "francesco.rossi@comune.reggioemilia.it"
7373
affiliation: Comune di Reggio Emilia
74-
phone: +39 231 13215112
74+
phone: +3923113215112
7575
- name: Dario Bianchi
7676
email: "dario.bianchi@fornitore.it"
7777
affiliation: Fornitore Privato S.P.A.
78-
phone: +39 16 24231322
78+
phone: +391624231322
7979
- name: Giancarlo Verdi
8080
email: "dario.bianchi@fornitore.it"
8181
affiliation: Fornitore Privato S.P.A.
82-
phone: +39 16 24231322
82+
phone: +391624231322
8383

8484
localisation:
8585
localisationReady: true

‎testdata/v0/valid_with_warnings/valid_with_it_conforme.yml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,15 @@ maintenance:
7171
- name: Francesco Rossi
7272
email: "francesco.rossi@comune.reggioemilia.it"
7373
affiliation: Comune di Reggio Emilia
74-
phone: +39 231 13215112
74+
phone: +3923113215112
7575
- name: Dario Bianchi
7676
email: "dario.bianchi@fornitore.it"
7777
affiliation: Fornitore Privato S.P.A.
78-
phone: +39 16 24231322
78+
phone: +391624231322
7979
- name: Giancarlo Verdi
8080
email: "dario.bianchi@fornitore.it"
8181
affiliation: Fornitore Privato S.P.A.
82-
phone: +39 16 24231322
82+
phone: +391624231322
8383

8484
localisation:
8585
localisationReady: true

‎testdata/v0/valid_with_warnings/valid_with_legal_repoOwner.yml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,15 @@ maintenance:
7373
- name: Francesco Rossi
7474
email: "francesco.rossi@comune.reggioemilia.it"
7575
affiliation: Comune di Reggio Emilia
76-
phone: +39 231 13215112
76+
phone: +3923113215112
7777
- name: Dario Bianchi
7878
email: "dario.bianchi@fornitore.it"
7979
affiliation: Fornitore Privato S.P.A.
80-
phone: +39 16 24231322
80+
phone: +391624231322
8181
- name: Giancarlo Verdi
8282
email: "dario.bianchi@fornitore.it"
8383
affiliation: Fornitore Privato S.P.A.
84-
phone: +39 16 24231322
84+
phone: +391624231322
8585

8686
localisation:
8787
localisationReady: true

0 commit comments

Comments
 (0)