Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve documents validation message #832

Open
MattiSG opened this issue Apr 22, 2022 · 5 comments
Open

Improve documents validation message #832

MattiSG opened this issue Apr 22, 2022 · 5 comments
Labels
good first issue Good for newcomers

Comments

@MattiSG
Copy link
Member

MattiSG commented Apr 22, 2022

Declaration validation does not consider an empty documents key as an error.

What happened

I tried to validate with npm run validate Example this malformed declaration:

{
  "name": "Example",
  "documents": { },
  "Terms of Service": {
    "fetch": "https://domain.example/tos",
    "select": "body"
  }
}

I got the following error:

data should not have additional elements

What I expected

An error in the style of:

`documents` cannot be empty, it should contain at least one of “Terms of Service”, “Imprint”…
@martinratinaud
Copy link
Member

I believe documents can be empty (at least for now)

We needed to do this for OkCupid so that we stop tracking it but still keep track that it ever existed here.
Let's discuss this in next planification then.

@MattiSG
Copy link
Member Author

MattiSG commented May 3, 2022

After discussion, the best option seems to be to load both history files and declaration files so that closed and suspended services are made available. However, this has important consequences. For example, the name key is currently declared only in the main service declaration, not in its history. Allowing history files to be first-class declarations means duplicating this information, with a risk of divergence.

Instead of allowing a double declaration, the best way to improve the error messages seems to reformat it in the testing code instead of displaying to the contributor the message provided by the validator. Indeed, the error is:

{
  keyword: 'additionalProperties',
  dataPath: '',
  schemaPath: '#/additionalProperties',
  params: { additionalProperty: 'Terms of Service' },
  message: 'should NOT have additional properties'
} 

…we could thus give additional details on how to fix this error.

@MattiSG
Copy link
Member Author

MattiSG commented May 3, 2022

@Manu1400 if you want to have a look, that could be a good way to improve the validator 🙂 @Ndpnt could help you navigate the code if needed.

@MattiSG MattiSG changed the title Validate documents key in declaration files Improve documents validation message May 18, 2022
@MattiSG MattiSG moved this from Considered to To assess in OpenTermsArchive Core Nov 16, 2022
@shravan562

This comment was marked as spam.

@MattiSG

This comment was marked as outdated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants