Skip to content

Programatic interface for instance validation #136

@kenloen

Description

@kenloen

Ported from comment on #75

When a user wants to validate an instance of the windIO schema they are required to know the "path" or "name" of the schema (e.g. plant/wind_farm, turbine/turbine_schema) which can be a slight inconvenience that one might have to leave to script to figure out the name of the schema.

To make this interface slightly more accessible, we could consider changing the windIO.validate method into a nested class where the different schemas are attributes, something along the lines of:

class PlantValidator:
  def __call__(self, file_or_data):
    validate_yaml(file_or_data, <plant-schema.yaml>)

class TurbineValidator:
  def __call__(self, file_or_data):
    validate_yaml(file_or_data, <turbine-schema.yaml>)

class windIOValidator:
  plant = PlantValidator()
  turbine = TurbineValidator()

Where the validation would then look something like:

from windIO import windIOValidator

windIOValidator.plant(file_or_data")

windIOValidator.turbine(file_or_data)

Another option would also be to serve our schemas and then users would be able to add the $schema key to the instance in which case the validator would be able to figure out which schema to use. This is linked with this issue #31 .

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestpython-libraryRelated to the python library

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions