feat: adds validation logic with model load and initial validation logic #43
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Adds option to validate when loading a model from an io.Reader. A noop validation is added for testing or when skipping validation is desired. A schema validator is added for validation against the OSCAL JSON schemas.
Rationale
The implemented validation logic is meant to be a post-decoding semantic validation of the models where a validation interface is added. The goal is to allow customized validation including combined validations before after decoding and before encoding. Adding the schema validation after unmarshaling to a struct has some performance overhead because of the requirement to encode back to JSON for validation against the schema.
Implementation for schema validation on raw JSON before decoding with this solution
With this solution the schema validation can still be done before load using a solution like the following with the underlying
go-oscal
validatorFixes #40
Will need rebase after #36 merge
How has this been tested?
Types of changes
Quality assurance (all should be covered).