[scd] Validate Volume4D when parsing#1380
Open
RustedBones wants to merge 1 commit intointeruss:masterfrom
Open
[scd] Validate Volume4D when parsing#1380RustedBones wants to merge 1 commit intointeruss:masterfrom
RustedBones wants to merge 1 commit intointeruss:masterfrom
Conversation
51e5d77 to
9a11fcb
Compare
9a11fcb to
6ff791d
Compare
mickmis
reviewed
Mar 11, 2026
Contributor
mickmis
left a comment
There was a problem hiding this comment.
Intent SGTM, I do have suggestions regarding implementation, please LMK what you think.
| // Volume4DFromSCDRest converts vol4 SCD v1 REST model to a Volume4D | ||
| func Volume4DFromSCDRest(vol4 *restapi.Volume4D) (*Volume4D, error) { | ||
| vol3, err := Volume3DFromSCDRest(&vol4.Volume) | ||
| func Volume4DFromSCDRest(vol4 *restapi.Volume4D, opts Volume4DOpts) (*Volume4D, error) { |
Contributor
There was a problem hiding this comment.
Using something inspired from the options/builder patterns could provide a cleaner and extensible interface here, i.e. sth like:
type Volume4DValidator func(*Volume4D) error
func WithRequireTimeBounds() Volume4DValidator {
return func(v *Volume4D) {
if v.StartTime == nil {
return fmt.Errorf("no start time")
}
if v.EndTime == nil {
return fmt.Errorf("no end time")
}
}
}
func Volume4DFromSCDRest(vol4 *restapi.Volume4D, validators ...Volume4DValidator) (*Volume4D, error) {
...
for _, validator := range validators {
if err := validator(svc); err != nil {
...
}
}
...
}| }, nil | ||
| } | ||
|
|
||
| type Volume3DOpts struct { |
Contributor
There was a problem hiding this comment.
Do we actually ever need to validate those directly on a Volume3D? If not consider doing the validation only from Volume4DFromSCDRest.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Factorize validation for
Volume3DandVolume4Dduring parsing:startTime<endTimewhen definedaltLo<altHiwhen definedIntroduce parsing options to tune validation:
altLoandaltHiset whenRequireAltitudeBoundsenabledstartTimeansendTimeset whenRequireTimeBoundsenabledConfiguration options for SCD entities mutation:
RequireTimeBounds: true, RequireAltitudeBounds: trueRequireTimeBounds: true, RequireAltitudeBounds: falseRequireTimeBounds: false, RequireAltitudeBounds: falseFor SCD queries:
RequireTimeBounds: false, RequireAltitudeBounds: false