-
Notifications
You must be signed in to change notification settings - Fork 88
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
Dynamic validation based on keys in data (internal reference) #253
Comments
Similar feature has been requested earlier: #154 |
I hadn't noticed that one, my apologies. I'm not sure why it's not within the scope of this project. Internal references are common, and since the file is read anyway, the schema can be dynamic in that sense... |
The validators themselves only have access to the object being validated, so I imagine this would require quite a large refactoring of the project to support this. |
Is that the case? It's been a while since I contributed to the project so I don't recall the details, but it seems that in schema.py#L80, the full contents of That would suggest, for example, that this type of validators would be deferred until data is provided. |
Its the Validator class that is used to validate an object, which only receives the object it self, not the full yaml file. So this can't be solved by simply introducing a new validator. |
Of course this would require a bit more complicated implementation (i.e. not simply subclassing the If I understand correctly, the full flow is as follows:
So, my suggestion would then be to allow a deferment of validators at a higher level here. For example, a |
Hi, Five years ago, I propose two new Validators in #82 that may answer your need. My PR was refused because leaders doesn't want dynamics schema. In some way that's a good practice to have static shema. Arnaud. |
Hey,
I have a thought for dynamic schema validation that I think is currently lacking (perhaps not too common request, though I believe it can be implemented as another validator).
In this case, I have a data YAML file where a mapping is expected. The keys may be anything the user decides, and the values are according to some predefined schema - so far, so good.
Next, at a later part in the data YAML, some other mapping occurs. Here, the value of the mapping has to relate to the keys defined earlier.
For example (a data YAML):
The text was updated successfully, but these errors were encountered: