OpenJobDescription / openjd-model-for-python

Provides a Python implementation of the data model for Open Job Description's template schemas.
https://github.com/OpenJobDescription/openjd-specifications/wiki
Apache License 2.0
12 stars 7 forks source link

feat: add validation that associative op's args are equal length #96

Closed ddneilson closed 5 months ago

ddneilson commented 5 months ago

What was the problem/requirement? (What/Why)

The Open Job Description specification says "Every comma-separated expression within an associative operator must have the exact same number of values defined in their range." The current model validators to not ensure that this is the case.

Reference: https://github.com/OpenJobDescription/openjd-specifications/wiki/2023-09-Template-Schemas#343-combinationexpr

What was the solution? (How)

I've implemented validate_step_parameter_space_dimensions() to validate this constraint and added a validator to the StepParameterSpace to use it. My first inclination was to implement this validation as part of constructing the StepParameterSpaceIterator since it already has a recursive expression parse, but that is a chicken & egg problem; we need a StepParameterSpace to construct a StepParameterSpaceIterator, but we don't have one yet when doing validation for the construction of a StepParameterSpace.

What is the impact of this change?

The model validator enforces a previously neglected constraint.

How was this change tested?

I have added unit tests that fully cover the new functionality.

Was this change documented?

Yes, in the official specification

Is this a breaking change?

No


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.