Skip to content
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

Reduce redundancy for RootProperty validation #232

Open
javagl opened this issue Oct 14, 2022 · 0 comments
Open

Reduce redundancy for RootProperty validation #232

javagl opened this issue Oct 14, 2022 · 0 comments

Comments

@javagl
Copy link
Contributor

javagl commented Oct 14, 2022

The validation of each rootProperty 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant