-
Notifications
You must be signed in to change notification settings - Fork 12
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
Object dependency relationships validation #153
Comments
Thank you!
I agree that a validation 100% based on schemas would be better if possible. There are a lot of benefits to that! I must point out that using only "main" schemas and patching them to add the other rules is complex: if two rules need to patch the same path, it may be very hard to do it without one overriding the other, and if it works, any small edition in one of the rule could break the other, so exhaustive automatic tests must be in place if done. Maybe a solution could be to use "main" schemas and generating some others instead of patching? (I don't have the bandwidth to work on it, but I wanted to highlight that issue, which made me use JS validation instead.) |
I must chime in: thanks for the incredible effort you've put down @tdelmas!
Yes I agree, the added complexity is a downside, but
This is a great idea actually! Either via a builder or a template. The benefit of this is that we can give each added rule a unique schema id and description, so it will be easier to identify in the result as well. I wouldn't mind exploring this option a little further actually. |
Probably also relevant for #154 |
What is the issue and why is it an issue?
The validator cannot currently validate object dependency relationships. This can lead to errors in the feeds that are difficult to identify and fix by the producer.
In #106, @tdelmas did a remarquable job of validating these dependencies using imperative rules (in JavaScript). Which works very well! However, this validation pattern may be harder to maintain over time in a community based tool which already uses JSON schemas and schema patching patterns.
Please describe some potential solutions you have considered (even if they aren’t related to GBFS).
As pointed by @testower here, there is a benefit of using schemas and patched schemas only because the validation itself is done by ajv and all the results are an output of ajv.
Object dependency relationships can be validated by applying these 3 rules:
Primary key validation
Example: Validate that each
station_id
MUST be unique in station_information.json.Potential solution: Use ajv #uniqueItemProperties (IDs must be unique in Arrays of objects).
Foreign key validation
Example: Validate that each
station_id
in station_status.json MUST exist in station_information.json.Potential solution: Use JSON Schema patching #Enumerated values (the Foreign Key ID must exist among the Primary Key IDs).
Cardinality validation
Example: Validate that each station in station_information.json MUST have exactly one entry in station_status.json.
Potential solution: Use JSON Schema patching #Length (the length of the Arrays is the same), combined with the 2 rules above.
Primary key fields
Foreign key fields
Fields with cardinality constraint
Implementation
Thank you all for your many great contributions already!
The text was updated successfully, but these errors were encountered: