Skip to content

Commit bbae225

Browse files
authored
fix: properly validate countryExtensionVersion (italia#197)
The standard states that countryExtensionVersion must be "1.0". Keep "0.2" for retrocompatibility, as that wasn't a great idea to bump it. The change was made when the process was not refined yet. countryExtensionVersion should and will be deprecated anyway.
1 parent 30b2c29 commit bbae225

File tree

3 files changed

+4
-8
lines changed

3 files changed

+4
-8
lines changed

fields.go

-7
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,6 @@ func validateFieldsV0(publiccode PublicCode, parser Parser, network bool) error
8181
}
8282
}
8383

84-
if publiccodev0.It.CountryExtensionVersion != "" && publiccodev0.It.CountryExtensionVersion != "0.2" {
85-
vr = append(vr, newValidationError(
86-
"it.countryExtensionVersion",
87-
"version %s not supported for country-specific section 'it'", publiccodev0.It.CountryExtensionVersion,
88-
))
89-
}
90-
9184
if len(publiccodev0.InputTypes) > 0 {
9285
vr = append(vr, ValidationWarning{"inputTypes", "This key is DEPRECATED and will be removed in the future", 0, 0})
9386
}

parser_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,9 @@ func TestInvalidTestcasesV0(t *testing.T) {
537537
},
538538

539539
// it.*
540+
"it_countryExtensionVersion_invalid.yml": ValidationResults{
541+
ValidationError{"it.countryExtensionVersion", "must be one of the following: 0.2 1.0", 12, 3},
542+
},
540543
"it_riuso_codiceIPA_invalid.yml": ValidationResults{
541544
ValidationError{"it.riuso.codiceIPA", "must be a valid Italian Public Administration Code (iPA)", 55, 5},
542545
},

v0.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ type DependencyV0 struct {
117117
// countries, such as declaring compliance with local laws or regulations.
118118

119119
type ITSectionV0 struct {
120-
CountryExtensionVersion string `yaml:"countryExtensionVersion"`
120+
CountryExtensionVersion *string `yaml:"countryExtensionVersion" validate:"omitnil,oneof=0.2 1.0"`
121121

122122
Conforme struct {
123123
LineeGuidaDesign bool `yaml:"lineeGuidaDesign,omitempty"`

0 commit comments

Comments
 (0)