From 4ab223848f2a2a456e8b5d9c606b9556e61e1aac Mon Sep 17 00:00:00 2001 From: Valerio Como Date: Thu, 12 Jun 2025 08:29:35 +0000 Subject: [PATCH] feat: contractors and contacts validation --- .devcontainer/devcontainer.json | 24 ++++++++ parser.go | 3 + parser_test.go | 44 ++++++++++++-- testdata/v0/invalid/landingURL_invalid.yml | 14 ----- testdata/v0/invalid/landingURL_wrong_type.yml | 14 ----- ...nce_contacts_excluded_if_type_contract.yml | 57 +++++++++++++++++++ ...tenance_contacts_excluded_if_type_none.yml | 52 +++++++++++++++++ ...contractors_excluded_if_type_community.yml | 57 +++++++++++++++++++ ..._contractors_excluded_if_type_internal.yml | 57 +++++++++++++++++++ ...ance_contractors_excluded_if_type_none.yml | 55 ++++++++++++++++++ .../v0/invalid/maintenance_type_invalid.yml | 3 - .../v0/invalid/maintenance_type_missing.yml | 3 - .../invalid/no-network/landingURL_invalid.yml | 14 ----- ...intenance_contacts_with_type_community.yml | 56 ++++++++++++++++++ ...aintenance_contacts_with_type_internal.yml | 56 ++++++++++++++++++ ...tenance_contractors_with_type_contract.yml | 54 ++++++++++++++++++ testdata/v0/valid/no-network/valid.yml | 14 ----- testdata/v0/valid/valid.yml | 14 ----- v0.go | 12 ++-- 19 files changed, 517 insertions(+), 86 deletions(-) create mode 100644 .devcontainer/devcontainer.json create mode 100644 testdata/v0/invalid/maintenance_contacts_excluded_if_type_contract.yml create mode 100644 testdata/v0/invalid/maintenance_contacts_excluded_if_type_none.yml create mode 100644 testdata/v0/invalid/maintenance_contractors_excluded_if_type_community.yml create mode 100644 testdata/v0/invalid/maintenance_contractors_excluded_if_type_internal.yml create mode 100644 testdata/v0/invalid/maintenance_contractors_excluded_if_type_none.yml create mode 100644 testdata/v0/valid/maintenance_contacts_with_type_community.yml create mode 100644 testdata/v0/valid/maintenance_contacts_with_type_internal.yml create mode 100644 testdata/v0/valid/maintenance_contractors_with_type_contract.yml diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..4f084661 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,24 @@ +{ + "name": "PublicCodeGoParser", + "runArgs": [ + "--name=PublicCodeGoParser" + ], + "image": "mcr.microsoft.com/devcontainers/go:1-1.23-bookworm", + "features": { + "ghcr.io/devcontainers/features/docker-in-docker:2": { + "moby": true, + "azureDnsAutoDetection": true, + "installDockerBuildx": true, + "installDockerComposeSwitch": true, + "version": "latest", + "dockerDashComposeVersion": "v2" + } + }, + "customizations": { + "vscode": { + "extensions": [ + "redhat.vscode-yaml" + ] + } + } +} diff --git a/parser.go b/parser.go index 578ecb9c..488e2f79 100644 --- a/parser.go +++ b/parser.go @@ -193,6 +193,9 @@ func (p *Parser) ParseStream(in io.Reader) (PublicCode, error) { "iso3166_1_alpha2_lowercase": "must be a valid lowercase ISO 3166-1 alpha-2 two-letter country code", "bcp47_language_tag": "must be a valid BCP 47 language", "bcp47_keys": "must use a valid BCP 47 language", + "required_if": "must be present if", + "excluded_unless": "must not be present unless", + "excluded_unless=Type community|excluded_unless=Type internal": "must not be present unless Type is community or internal", } for _, err := range err.(validator.ValidationErrors) { var sb strings.Builder diff --git a/parser_test.go b/parser_test.go index fa1043a7..8471edaf 100644 --- a/parser_test.go +++ b/parser_test.go @@ -458,16 +458,31 @@ func TestInvalidTestcasesV0(t *testing.T) { // maintenance // maintenance.* "maintenance_type_missing.yml": ValidationResults{ - ValidationError{"maintenance.type", "required", 47, 3}, + ValidationError{"maintenance.type", "required", 43, 13}, }, "maintenance_type_invalid.yml": ValidationResults{ ValidationError{"maintenance.type", "must be one of the following: internal contract community none", 45, 3}, }, + "maintenance_contractors_excluded_if_type_community.yml": ValidationResults{ + ValidationError{"maintenance.contractors", "must not be present unless Type contract", 47, 3}, + }, + "maintenance_contractors_excluded_if_type_internal.yml": ValidationResults{ + ValidationError{"maintenance.contractors", "must not be present unless Type contract", 47, 3}, + }, + "maintenance_contractors_excluded_if_type_none.yml": ValidationResults{ + ValidationError{"maintenance.contractors", "must not be present unless Type contract", 47, 3}, + }, "maintenance_contacts_missing_with_type_community.yml": ValidationResults{ - ValidationError{"maintenance.contacts", "required_if Type community", 44, 3}, + ValidationError{"maintenance.contacts", "must be present if Type community", 44, 3}, }, "maintenance_contacts_missing_with_type_internal.yml": ValidationResults{ - ValidationError{"maintenance.contacts", "required_if Type internal", 44, 3}, + ValidationError{"maintenance.contacts", "must be present if Type internal", 44, 3}, + }, + "maintenance_contacts_excluded_if_type_contract.yml": ValidationResults{ + ValidationError{"maintenance.contacts", "must not be present unless Type is community or internal Type internal", 51, 3}, + }, + "maintenance_contacts_excluded_if_type_none.yml": ValidationResults{ + ValidationError{"maintenance.contacts", "must not be present unless Type is community or internal Type internal", 46, 3}, }, "maintenance_contacts_name_missing.yml": ValidationResults{ ValidationError{"maintenance.contacts[0].name", "required", 0, 0}, @@ -476,11 +491,11 @@ func TestInvalidTestcasesV0(t *testing.T) { ValidationError{"maintenance.contacts[0].email", "must be a valid email", 0, 0}, }, "maintenance_contractors_missing_with_type_contract.yml": ValidationResults{ - ValidationError{"maintenance.contractors", "required_if Type contract", 44, 3}, + ValidationError{"maintenance.contractors", "must be present if Type contract", 44, 3}, }, "maintenance_contractors_invalid_type.yml": ValidationResults{ ValidationError{"maintenance.contractors", "wrong type for this field", 47, 1}, - ValidationError{"maintenance.contractors", "required_if Type contract", 47, 3}, + ValidationError{"maintenance.contractors", "must be present if Type contract", 47, 3}, }, "maintenance_contractors_name_missing.yml": ValidationResults{ ValidationError{"maintenance.contractors[0].name", "required", 0, 0}, @@ -736,3 +751,22 @@ func TestToURL(t *testing.T) { } } } + +func TestInvalidContractorsMustBeIgnored(t *testing.T) { + expected := error( + ValidationResults{ + ValidationError{"maintenance.contractors", "must not be present unless Type contract", 47, 3}, + }, + ) + + parser, errParser := NewParser(ParserConfig{DisableNetwork: true}) + if errParser != nil { + t.Errorf("Can't create Parser: %v", errParser) + } + var file = "testdata/v0/invalid/maintenance_contractors_excluded_if_type_community.yml" + _, err := parser.Parse(file) + + if err != nil && expected != nil && err.Error() != expected.Error() { + t.Errorf("Expected contractors excluded_if error") + } +} diff --git a/testdata/v0/invalid/landingURL_invalid.yml b/testdata/v0/invalid/landingURL_invalid.yml index f1a774ee..5c7c5968 100644 --- a/testdata/v0/invalid/landingURL_invalid.yml +++ b/testdata/v0/invalid/landingURL_invalid.yml @@ -79,20 +79,6 @@ maintenance: website: "https://developers.italia.it" until: "2019-01-01" - contacts: - - name: Francesco Rossi - email: "francesco.rossi@comune.reggioemilia.it" - affiliation: Comune di Reggio Emilia - phone: +39 231 13215112 - - name: Dario Bianchi - email: "dario.bianchi@fornitore.it" - affiliation: Fornitore Privato S.P.A. - phone: +39 16 24231322 - - name: Giancarlo Verdi - email: "dario.bianchi@fornitore.it" - affiliation: Fornitore Privato S.P.A. - phone: +39 16 24231322 - localisation: localisationReady: true availableLanguages: diff --git a/testdata/v0/invalid/landingURL_wrong_type.yml b/testdata/v0/invalid/landingURL_wrong_type.yml index ba2fda2e..b889fa09 100644 --- a/testdata/v0/invalid/landingURL_wrong_type.yml +++ b/testdata/v0/invalid/landingURL_wrong_type.yml @@ -75,20 +75,6 @@ maintenance: website: "https://developers.italia.it" until: "2019-01-01" - contacts: - - name: Francesco Rossi - email: "francesco.rossi@comune.reggioemilia.it" - affiliation: Comune di Reggio Emilia - phone: +39 231 13215112 - - name: Dario Bianchi - email: "dario.bianchi@fornitore.it" - affiliation: Fornitore Privato S.P.A. - phone: +39 16 24231322 - - name: Giancarlo Verdi - email: "dario.bianchi@fornitore.it" - affiliation: Fornitore Privato S.P.A. - phone: +39 16 24231322 - localisation: localisationReady: true availableLanguages: diff --git a/testdata/v0/invalid/maintenance_contacts_excluded_if_type_contract.yml b/testdata/v0/invalid/maintenance_contacts_excluded_if_type_contract.yml new file mode 100644 index 00000000..c749103a --- /dev/null +++ b/testdata/v0/invalid/maintenance_contacts_excluded_if_type_contract.yml @@ -0,0 +1,57 @@ +publiccodeYmlVersion: "0.4" + +name: Medusa +url: "https://github.com/italia/developers.italia.it.git" +softwareVersion: "dev" +releaseDate: "2017-04-15" + +platforms: + - web + +categories: + - cloud-management + +developmentStatus: development + +softwareType: "standalone/other" + +description: + en: + localisedName: Medusa + shortDescription: > + A rather short description which + is probably useless + longDescription: > + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 158 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 316 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 474 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 632 characters. + features: + - Just one feature + +legal: + license: AGPL-3.0-or-later + +maintenance: + type: "contract" + + # Should NOT validate: invalid payload + contractors: + - name: "Fornitore Privato SPA" + website: "https://developers.italia.it" + until: "2019-01-01" + contacts: + - name: Francesco Rossi + +localisation: + localisationReady: true + availableLanguages: + - en diff --git a/testdata/v0/invalid/maintenance_contacts_excluded_if_type_none.yml b/testdata/v0/invalid/maintenance_contacts_excluded_if_type_none.yml new file mode 100644 index 00000000..45cfd416 --- /dev/null +++ b/testdata/v0/invalid/maintenance_contacts_excluded_if_type_none.yml @@ -0,0 +1,52 @@ +publiccodeYmlVersion: "0.4" + +name: Medusa +url: "https://github.com/italia/developers.italia.it.git" +softwareVersion: "dev" +releaseDate: "2017-04-15" + +platforms: + - web + +categories: + - cloud-management + +developmentStatus: development + +softwareType: "standalone/other" + +description: + en: + localisedName: Medusa + shortDescription: > + A rather short description which + is probably useless + longDescription: > + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 158 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 316 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 474 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 632 characters. + features: + - Just one feature + +legal: + license: AGPL-3.0-or-later + +maintenance: + type: "none" + + contacts: + - name: Francesco Rossi + +localisation: + localisationReady: true + availableLanguages: + - en diff --git a/testdata/v0/invalid/maintenance_contractors_excluded_if_type_community.yml b/testdata/v0/invalid/maintenance_contractors_excluded_if_type_community.yml new file mode 100644 index 00000000..7b27c332 --- /dev/null +++ b/testdata/v0/invalid/maintenance_contractors_excluded_if_type_community.yml @@ -0,0 +1,57 @@ +publiccodeYmlVersion: "0.4" + +name: Medusa +url: "https://github.com/italia/developers.italia.it.git" +softwareVersion: "dev" +releaseDate: "2017-04-15" + +platforms: + - web + +categories: + - cloud-management + +developmentStatus: development + +softwareType: "standalone/other" + +description: + en: + localisedName: Medusa + shortDescription: > + A rather short description which + is probably useless + longDescription: > + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 158 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 316 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 474 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 632 characters. + features: + - Just one feature + +legal: + license: AGPL-3.0-or-later + +maintenance: + type: "community" + + # Should NOT validate: invalid payload + contractors: + - name: "Fornitore Privato SPA" + website: "https://developers.italia.it" + # until: "2019-01-01" + contacts: + - name: Francesco Rossi + +localisation: + localisationReady: true + availableLanguages: + - en diff --git a/testdata/v0/invalid/maintenance_contractors_excluded_if_type_internal.yml b/testdata/v0/invalid/maintenance_contractors_excluded_if_type_internal.yml new file mode 100644 index 00000000..237686f3 --- /dev/null +++ b/testdata/v0/invalid/maintenance_contractors_excluded_if_type_internal.yml @@ -0,0 +1,57 @@ +publiccodeYmlVersion: "0.4" + +name: Medusa +url: "https://github.com/italia/developers.italia.it.git" +softwareVersion: "dev" +releaseDate: "2017-04-15" + +platforms: + - web + +categories: + - cloud-management + +developmentStatus: development + +softwareType: "standalone/other" + +description: + en: + localisedName: Medusa + shortDescription: > + A rather short description which + is probably useless + longDescription: > + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 158 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 316 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 474 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 632 characters. + features: + - Just one feature + +legal: + license: AGPL-3.0-or-later + +maintenance: + type: "internal" + + # Should NOT validate: invalid payload + contractors: + - name: "Fornitore Privato SPA" + website: "https://developers.italia.it" + # until: "2019-01-01" + contacts: + - name: Francesco Rossi + +localisation: + localisationReady: true + availableLanguages: + - en diff --git a/testdata/v0/invalid/maintenance_contractors_excluded_if_type_none.yml b/testdata/v0/invalid/maintenance_contractors_excluded_if_type_none.yml new file mode 100644 index 00000000..be327bfa --- /dev/null +++ b/testdata/v0/invalid/maintenance_contractors_excluded_if_type_none.yml @@ -0,0 +1,55 @@ +publiccodeYmlVersion: "0.4" + +name: Medusa +url: "https://github.com/italia/developers.italia.it.git" +softwareVersion: "dev" +releaseDate: "2017-04-15" + +platforms: + - web + +categories: + - cloud-management + +developmentStatus: development + +softwareType: "standalone/other" + +description: + en: + localisedName: Medusa + shortDescription: > + A rather short description which + is probably useless + longDescription: > + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 158 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 316 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 474 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 632 characters. + features: + - Just one feature + +legal: + license: AGPL-3.0-or-later + +maintenance: + type: "none" + + # Should NOT validate: invalid payload + contractors: + - name: "Fornitore Privato SPA" + website: "https://developers.italia.it" + # until: "2019-01-01" + +localisation: + localisationReady: true + availableLanguages: + - en diff --git a/testdata/v0/invalid/maintenance_type_invalid.yml b/testdata/v0/invalid/maintenance_type_invalid.yml index 659280a5..62524dc7 100644 --- a/testdata/v0/invalid/maintenance_type_invalid.yml +++ b/testdata/v0/invalid/maintenance_type_invalid.yml @@ -44,9 +44,6 @@ maintenance: # Should NOT validate: invalid type type: "no_such_type" - contacts: - - name: Francesco Rossi - localisation: localisationReady: true availableLanguages: diff --git a/testdata/v0/invalid/maintenance_type_missing.yml b/testdata/v0/invalid/maintenance_type_missing.yml index 72e115c9..64cc9adf 100644 --- a/testdata/v0/invalid/maintenance_type_missing.yml +++ b/testdata/v0/invalid/maintenance_type_missing.yml @@ -44,9 +44,6 @@ maintenance: # Should NOT validate: type is missing # type: "community" - contacts: - - name: Francesco Rossi - localisation: localisationReady: true availableLanguages: diff --git a/testdata/v0/invalid/no-network/landingURL_invalid.yml b/testdata/v0/invalid/no-network/landingURL_invalid.yml index f1a774ee..5c7c5968 100644 --- a/testdata/v0/invalid/no-network/landingURL_invalid.yml +++ b/testdata/v0/invalid/no-network/landingURL_invalid.yml @@ -79,20 +79,6 @@ maintenance: website: "https://developers.italia.it" until: "2019-01-01" - contacts: - - name: Francesco Rossi - email: "francesco.rossi@comune.reggioemilia.it" - affiliation: Comune di Reggio Emilia - phone: +39 231 13215112 - - name: Dario Bianchi - email: "dario.bianchi@fornitore.it" - affiliation: Fornitore Privato S.P.A. - phone: +39 16 24231322 - - name: Giancarlo Verdi - email: "dario.bianchi@fornitore.it" - affiliation: Fornitore Privato S.P.A. - phone: +39 16 24231322 - localisation: localisationReady: true availableLanguages: diff --git a/testdata/v0/valid/maintenance_contacts_with_type_community.yml b/testdata/v0/valid/maintenance_contacts_with_type_community.yml new file mode 100644 index 00000000..7976d237 --- /dev/null +++ b/testdata/v0/valid/maintenance_contacts_with_type_community.yml @@ -0,0 +1,56 @@ +publiccodeYmlVersion: "0.4" + +name: Medusa +url: "https://github.com/italia/developers.italia.it.git" +softwareVersion: "dev" +releaseDate: "2017-04-15" + +platforms: + - web + +categories: + - cloud-management + +developmentStatus: development + +softwareType: "standalone/other" + +description: + en: + localisedName: Medusa + shortDescription: > + A rather short description which + is probably useless + longDescription: > + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 158 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 316 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 474 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 632 characters. + features: + - Just one feature + +legal: + license: AGPL-3.0-or-later + +maintenance: + type: "community" + + contacts: + - name: Dario Bianchi + email: "dario.bianchi@fornitore.it" + + - name: Giancarlo Verdi + email: "dario.bianchi@fornitore.it" + +localisation: + localisationReady: true + availableLanguages: + - en diff --git a/testdata/v0/valid/maintenance_contacts_with_type_internal.yml b/testdata/v0/valid/maintenance_contacts_with_type_internal.yml new file mode 100644 index 00000000..ca8bb509 --- /dev/null +++ b/testdata/v0/valid/maintenance_contacts_with_type_internal.yml @@ -0,0 +1,56 @@ +publiccodeYmlVersion: "0.4" + +name: Medusa +url: "https://github.com/italia/developers.italia.it.git" +softwareVersion: "dev" +releaseDate: "2017-04-15" + +platforms: + - web + +categories: + - cloud-management + +developmentStatus: development + +softwareType: "standalone/other" + +description: + en: + localisedName: Medusa + shortDescription: > + A rather short description which + is probably useless + longDescription: > + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 158 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 316 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 474 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 632 characters. + features: + - Just one feature + +legal: + license: AGPL-3.0-or-later + +maintenance: + type: "internal" + + contacts: + - name: Dario Bianchi + email: "dario.bianchi@fornitore.it" + + - name: Giancarlo Verdi + email: "dario.bianchi@fornitore.it" + +localisation: + localisationReady: true + availableLanguages: + - en diff --git a/testdata/v0/valid/maintenance_contractors_with_type_contract.yml b/testdata/v0/valid/maintenance_contractors_with_type_contract.yml new file mode 100644 index 00000000..87a49e3d --- /dev/null +++ b/testdata/v0/valid/maintenance_contractors_with_type_contract.yml @@ -0,0 +1,54 @@ +publiccodeYmlVersion: "0.4" + +name: Medusa +url: "https://github.com/italia/developers.italia.it.git" +softwareVersion: "dev" +releaseDate: "2017-04-15" + +platforms: + - web + +categories: + - cloud-management + +developmentStatus: development + +softwareType: "standalone/other" + +description: + en: + localisedName: Medusa + shortDescription: > + A rather short description which + is probably useless + longDescription: > + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 158 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 316 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 474 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 632 characters. + features: + - Just one feature + +legal: + license: AGPL-3.0-or-later + +maintenance: + type: "contract" + + contractors: + - name: "Fornitore Privato SPA" + website: "https://developers.italia.it" + until: "2019-01-01" + +localisation: + localisationReady: true + availableLanguages: + - en diff --git a/testdata/v0/valid/no-network/valid.yml b/testdata/v0/valid/no-network/valid.yml index 587a4b98..365914c5 100644 --- a/testdata/v0/valid/no-network/valid.yml +++ b/testdata/v0/valid/no-network/valid.yml @@ -186,20 +186,6 @@ maintenance: website: "https://developers.italia.it" until: "2019-01-01" - contacts: - - name: Francesco Rossi - email: "francesco.rossi@example.org" - affiliation: Comune di Reggio Emilia - phone: +39 231 13215112 - - name: Dario Bianchi - email: "dario.bianchi@example.org" - affiliation: Fornitore Privato S.P.A. - phone: +39 16 24231322 - - name: Giancarlo Verdi - email: "dario.bianchi@example.org" - affiliation: Fornitore Privato S.P.A. - phone: +39 16 24231322 - localisation: localisationReady: true availableLanguages: diff --git a/testdata/v0/valid/valid.yml b/testdata/v0/valid/valid.yml index 46c9a4fa..f3c5ad5a 100644 --- a/testdata/v0/valid/valid.yml +++ b/testdata/v0/valid/valid.yml @@ -185,20 +185,6 @@ maintenance: website: "https://developers.italia.it" until: "2019-01-01" - contacts: - - name: Francesco Rossi - email: "francesco.rossi@example.org" - affiliation: Comune di Reggio Emilia - phone: +39 231 13215112 - - name: Dario Bianchi - email: "dario.bianchi@example.org" - affiliation: Fornitore Privato S.P.A. - phone: +39 16 24231322 - - name: Giancarlo Verdi - email: "dario.bianchi@example.org" - affiliation: Fornitore Privato S.P.A. - phone: +39 16 24231322 - localisation: localisationReady: true availableLanguages: diff --git a/v0.go b/v0.go index 929f20df..343fa9f2 100644 --- a/v0.go +++ b/v0.go @@ -50,11 +50,7 @@ type PublicCodeV0 struct { AuthorsFile *string `yaml:"authorsFile,omitempty"` } `yaml:"legal"` - Maintenance struct { - Type string `yaml:"type" validate:"required,oneof=internal contract community none"` - Contractors []ContractorV0 `yaml:"contractors,omitempty" validate:"required_if=Type contract,dive"` - Contacts []ContactV0 `yaml:"contacts,omitempty" validate:"required_if=Type community,required_if=Type internal,dive"` - } `yaml:"maintenance"` + Maintenance MaintenanceV0 `yaml:"maintenance"` Localisation struct { LocalisationReady *bool `yaml:"localisationReady" validate:"required"` @@ -84,6 +80,12 @@ type DescV0 struct { Awards []string `yaml:"awards,omitempty"` } +type MaintenanceV0 struct { + Type string `yaml:"type" validate:"required,oneof=internal contract community none"` + Contractors []ContractorV0 `yaml:"contractors,omitempty" validate:"excluded_unless=Type contract,required_if=Type contract,dive"` + Contacts []ContactV0 `yaml:"contacts,omitempty" validate:"excluded_unless=Type community|excluded_unless=Type internal,required_if=Type community,required_if=Type internal,dive"` +} + // ContractorV0 is an entity or entities, if any, that are currently contracted for maintaining the software. type ContractorV0 struct { Name string `yaml:"name" validate:"required"`