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

Validation of the rules file #17

Open
yjmantilla opened this issue Jun 30, 2021 · 3 comments
Open

Validation of the rules file #17

yjmantilla opened this issue Jun 30, 2021 · 3 comments
Assignees

Comments

@yjmantilla
Copy link
Owner

So I was thinking that given that the rules file could be done by a power-user then it would be good to have a validator for it; in a sense that it has the required fields and not unsupported fields and so on.

@yjmantilla yjmantilla self-assigned this Jun 30, 2021
@civier
Copy link
Collaborator

civier commented Jun 30, 2021

It good to have a validator in any case, to make sure there are no bugs in the code. If it's a yaml, so I'm sure that a validator can be automatically generated (without coding) by specifying the required fields, unsupported fields, etc.
Have you looked into what's available?

@yjmantilla
Copy link
Owner Author

yjmantilla commented Jun 30, 2021

Have you looked into what's available?

No until just now, one of the candidates from here is cerberus. The schema is defined as a json dictionary .

Nonetheless, the logic can be quite variable since, for example, the task name can be set up to a fixed value or inferred from a path pattern, so then the validator has to check that the task is in either of those fields. I'm not sure yet of how cerberus would be able to deal with that.

Another option is the schema package . Reading a bit into it, it seems it would be able to support the kind of logic I just mentioned.

There a whole bunch of other options listed there (Rx, kwalify, voluptuous, flatland) but those two (cerberus and schema) where the ones that upon a quick reading captured my attention.

@aswinnarayanan
Copy link
Collaborator

aswinnarayanan commented Jul 1, 2021

@yjmantilla
Another option could be jsonchema (Github)

It's an implementation of the bigger JSON Schema initiative which is in process to trying to become an IETF standard, which is promising. They have some other python implementations here as well

It should support yaml (detailed here).
I don't think we are planning to use the advanced yaml functions. And it could be beneficial in future if the validator is agnositic to json/yaml

JSON Schema is also supported by the Red Hat YAML extension for VS Code, so provides option for the user to validate their bids yaml from the VS code editor.

Your other options also look good, especially Cerberus.

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

No branches or pull requests

3 participants