Currently, the validator cannot validate whether the total value equals the sum of counts. This could lead to vehicle count mismatch in consuming applications.
This type of validation was proposed in https://github.com/MobilityData/gbfs-validator/pull/106 using imperative rules (in JavaScript). However, using schemas and patched schemas instead, would have the benefit of having the validation done by ajv and all the results as an output of ajv.
Example from the GBFS spec of a field which SHOULD add up to match the value of another field:
vehicle_types_available | The total number of vehicles from each of these objects SHOULD add up to match the value specified in the num_vehicles_available field.
Please describe some potential solutions you have considered (even if they aren’t related to GBFS).
Whether the total value equals the sum of counts could be validated using JSON Schema patching #Constant values.
If the validation fails, a WARNING should be generated because this rule is a recommendation in the spec, not a requirement.
Fields which SHOULD add up to match the value of another field
```
- station_information.json#stations.vehicle_types_capacity
- station_information.json#stations.vehicle_docks_capacity
- station_status.json#stations.vehicle_types_available
- station_status.json#stations.vehicle_docks_available
```
What is the issue and why is it an issue?
Currently, the validator cannot validate whether the total value equals the sum of counts. This could lead to vehicle count mismatch in consuming applications.
This type of validation was proposed in https://github.com/MobilityData/gbfs-validator/pull/106 using imperative rules (in JavaScript). However, using schemas and patched schemas instead, would have the benefit of having the validation done by ajv and all the results as an output of ajv.
Example from the GBFS spec of a field which SHOULD add up to match the value of another field:
Please describe some potential solutions you have considered (even if they aren’t related to GBFS).
Whether the total value equals the sum of counts could be validated using JSON Schema patching #Constant values.
If the validation fails, a WARNING should be generated because this rule is a recommendation in the spec, not a requirement.
As noted in https://github.com/MobilityData/gbfs-validator/issues/153#issuecomment-1806145023, a solution to reduce schema patching complexity could be to generate new schemas via a builder or a template instead of patching the main schemas.
Fields which SHOULD add up to match the value of another field
``` - station_information.json#stations.vehicle_types_capacity - station_information.json#stations.vehicle_docks_capacity - station_status.json#stations.vehicle_types_available - station_status.json#stations.vehicle_docks_available ```