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

Implement validators registry #79

Open
dalonsoa opened this issue Oct 1, 2024 · 0 comments
Open

Implement validators registry #79

dalonsoa opened this issue Oct 1, 2024 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers Hacktoberfest
Milestone

Comments

@dalonsoa
Copy link
Collaborator

dalonsoa commented Oct 1, 2024

Problem

The yaml header is meant to be flexible and there is no imposition of any specific fields that must be there. However, there are fields that, if present, must follow certain schema. An example of this are the CSV dialect (that will be implemented in #2) and the Tabular schema (implemented in #3). It is easy to see that other applications and tools might require their own strict set of fields, eg. an measurement equipment that provides as metadata machine make and model, start and end time of the measurements, and some specific machine settings. All of those must be there if the metadata is to truly represent the data it is accompanying.

Proposed solution

Implement a validator registry that will run specific, known validators on the header if a given field is present. Eg. assuming #3 is implemented

@register_validator(name="tabular")
class TabularSchema(...)
    ...

# and then, when reading the yaml header
for field, validator in VALIDATORS_REGISTRY.items():
    if field in yaml_header:
        yaml_header[field] = validator(field)

So the TabularSchema validator will run if tabular is a top level field in the yaml header. The same would be done when saving the data, but in that case, the validator would be dumping the data to a dict, so it can be saved.

This issue is not about implementing any specific validator, but about setting up the infrastructure for registering and running them.

@dalonsoa dalonsoa added Hacktoberfest enhancement New feature or request labels Oct 1, 2024
@dalonsoa dalonsoa added this to the v1.0.0 milestone Oct 1, 2024
@dalonsoa dalonsoa added the good first issue Good for newcomers label Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers Hacktoberfest
Projects
None yet
Development

No branches or pull requests

1 participant