CesiumGS / CesiumGS/3d-tiles-validator

Reduce redundancy for `RootProperty` validation

Open
#232 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
474
Forks
156
PR merge metrics
No merged PRs in 30d

Description

The validation of each [`rootProperty`](https://github.com/CesiumGS/3d-tiles/blob/21aba4796c8281f33e3235493ae9040b70a50bc8/specification/schema/common/rootProperty.schema.json) currently starts with a common block:

- Make sure that the given value is an object
- Validate the object as a RootProperty: Use the `RootPropertyValidator` to check that `extensions` and `extras` have a proper JSON structure)
- Perform the validation of the object in view of the extensions that it may contain: Use the `ExtendedObjectsValidators` to check whether the object contains a known extension object, and whether a special `Validator` was registered for that case
- If there was an extension validator that overrides the default validation, then skip the remaining validation.

It might also be worth considering to model the validation process more generally and explicitly as some sort of "chain", roughly as in the pseudocode

let result = true;
for (const step of chain) {
const stepResult = step.apply(input);
if (!stepResult.valid) result = false;
if (!stepResult.continueValidation) break;
}

The redundancy for now is not so high that it would warrant larger engineering efforts. But eventually, this could lead to a more flexible (and extensible) validation process in general, so should be considered at some point in time.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the rootProperty validation flow and the RootPropertyValidator and ExtendedObjectsValidators mentioned in the issue. Trace how each rootProperty repeats the object, RootProperty, extension, and override checks. Done means the common validation is centralized or modeled consistently without changing existing validation behavior; consider the proposed chain only if it fits the scope.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.