Skip to content

Commit 2f293bd

Browse files
committed
feat: require E.164 phone numbers in v1
phone numvers is now validated as E.164.
1 parent 1dac810 commit 2f293bd

6 files changed

Lines changed: 49 additions & 10 deletions

File tree

testdata/v1/invalid/landingURL_invalid.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,15 @@ maintenance:
8282
- name: Francesco Rossi
8383
email: "francesco.rossi@comune.reggioemilia.it"
8484
affiliation: Comune di Reggio Emilia
85-
phone: +39 231 13215112
85+
phone: +3923113215112
8686
- name: Dario Bianchi
8787
email: "dario.bianchi@fornitore.it"
8888
affiliation: Fornitore Privato S.P.A.
89-
phone: +39 16 24231322
89+
phone: +391624231322
9090
- name: Giancarlo Verdi
9191
email: "dario.bianchi@fornitore.it"
9292
affiliation: Fornitore Privato S.P.A.
93-
phone: +39 16 24231322
93+
phone: +391624231322
9494

9595
localisation:
9696
localisationReady: true

testdata/v1/invalid/landingURL_wrong_type.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,15 @@ maintenance:
7878
- name: Francesco Rossi
7979
email: "francesco.rossi@comune.reggioemilia.it"
8080
affiliation: Comune di Reggio Emilia
81-
phone: +39 231 13215112
81+
phone: +3923113215112
8282
- name: Dario Bianchi
8383
email: "dario.bianchi@fornitore.it"
8484
affiliation: Fornitore Privato S.P.A.
85-
phone: +39 16 24231322
85+
phone: +391624231322
8686
- name: Giancarlo Verdi
8787
email: "dario.bianchi@fornitore.it"
8888
affiliation: Fornitore Privato S.P.A.
89-
phone: +39 16 24231322
89+
phone: +391624231322
9090

9191
localisation:
9292
localisationReady: true
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
publiccodeYmlVersion: "1"
2+
3+
name: TestSoftware
4+
url: "https://github.com/italia/developers.italia.it.git"
5+
6+
platforms:
7+
- web
8+
9+
developmentStatus: stable
10+
11+
softwareType: "standalone/web"
12+
13+
description:
14+
en:
15+
shortDescription: "A test software for v1 parsing."
16+
longDescription: >
17+
This is a long description for the test software used to verify
18+
that the v1 parser works correctly. It needs to be at least 150
19+
characters long to pass validation checks in the publiccode.yml
20+
parser implementation. This is enough text now.
21+
features:
22+
- Test feature
23+
24+
legal:
25+
license: MIT
26+
27+
maintenance:
28+
type: internal
29+
contacts:
30+
- name: Test Contact
31+
phone: "06 1234567"
32+
33+
localisation:
34+
localisationReady: true
35+
availableLanguages:
36+
- en

testdata/v1/invalid/no-network/landingURL_invalid.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,15 @@ maintenance:
8282
- name: Francesco Rossi
8383
email: "francesco.rossi@comune.reggioemilia.it"
8484
affiliation: Comune di Reggio Emilia
85-
phone: +39 231 13215112
85+
phone: +3923113215112
8686
- name: Dario Bianchi
8787
email: "dario.bianchi@fornitore.it"
8888
affiliation: Fornitore Privato S.P.A.
89-
phone: +39 16 24231322
89+
phone: +391624231322
9090
- name: Giancarlo Verdi
9191
email: "dario.bianchi@fornitore.it"
9292
affiliation: Fornitore Privato S.P.A.
93-
phone: +39 16 24231322
93+
phone: +391624231322
9494

9595
localisation:
9696
localisationReady: true

v1.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ type ContactV1 struct {
9494
Name string `json:"name" validate:"required" yaml:"name"`
9595
Email *string `json:"email,omitempty" validate:"omitempty,email" yaml:"email,omitempty"`
9696
Affiliation *string `json:"affiliation,omitempty" yaml:"affiliation,omitempty"`
97-
Phone *string `json:"phone,omitempty" validate:"omitempty" yaml:"phone,omitempty"`
97+
Phone *string `json:"phone,omitempty" validate:"omitempty,e164" yaml:"phone,omitempty"`
9898
}
9999

100100
// DependencyV1 describes system-level dependencies required to install and use this software.

v1_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,9 @@ func TestInvalidTestcasesV1(t *testing.T) {
250250
"maintenance_contacts_email_invalid.yml": ValidationResults{
251251
ValidationError{"maintenance.contacts[0].email", "email must be a valid email address", 49, 9},
252252
},
253+
"maintenance_contacts_phone_invalid.yml": ValidationResults{
254+
ValidationError{"maintenance.contacts[0].phone", "phone must be a valid E.164 formatted phone number", 31, 7},
255+
},
253256
"maintenance_contacts_missing_with_type_community.yml": ValidationResults{
254257
ValidationError{"maintenance.contacts", "contacts is a required field when \"type\" is \"community\"", 44, 3},
255258
},

0 commit comments

Comments
 (0)