Add defensive validation to TimeSeries::try_new (closes #275) #276
+89
−1
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.
Closes #275
Summary
This PR adds defensive validation to TimeSeries::try_new to ensure the provided period and interval values satisfy the required multiple relationship and to prevent invalid inputs (such as zero interval). The change documents the error conditions, adds unit tests, and updates the CHANGELOG.
What I changed and why
Validate inputs in TimeSeries::try_new:
These checks make the implicit assumption explicit and protect future changes from violating the constraint.
Add rustdoc to TimeSeries::try_new
Add unit tests
Update CHANGELOG.md
Files changed
Quality assurance
Notes
This is a defensive/validation change only — it does not alter existing happy-path behavior when callers already provide valid period/interval pairs. The goal is to make the constraint explicit and fail early with clear errors if it's violated.