Skip to content

Add check_positive_decimal correctness function #2736

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

Merged
merged 2 commits into from
Jun 25, 2025
Merged

Add check_positive_decimal correctness function #2736

merged 2 commits into from
Jun 25, 2025

Conversation

nicolad
Copy link
Member

@nicolad nicolad commented Jun 25, 2025

Introduce check_positive_decimal in crates/core/src/correctness.rs to enforce that rust_decimal::Decimal parameters are strictly positive. The helper replaces hand-rolled checks inside validate_instrument_common, tightening validation for fields such as margin_init. Comprehensive rstest cases cover positive, zero, and negative edge conditions.

Impact

Non-breaking: only invalid (≤ 0) decimal inputs now fail early with a clear error message, improving safety while leaving existing valid workflows unchanged.

Notes

  • Added function‐level docs and #[inline(always)] hint.
  • Extended unit-test suite in both correctness and model::instruments modules.

@nicolad nicolad requested a review from cjdsellers June 25, 2025 05:50
@nicolad nicolad self-assigned this Jun 25, 2025
@nicolad nicolad added the rust Relating to the Rust core label Jun 25, 2025
@cjdsellers cjdsellers changed the title Rust instruments: implemented and used check_positive_decimal Add check_positive_decimal correctness function Jun 25, 2025
Copy link
Member

@cjdsellers cjdsellers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks @nicolad !

@nicolad nicolad requested a review from cjdsellers June 25, 2025 21:39
Copy link
Member

@cjdsellers cjdsellers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

@cjdsellers cjdsellers merged commit 9847e75 into develop Jun 25, 2025
13 checks passed
@cjdsellers cjdsellers deleted the 2630-2 branch June 25, 2025 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rust Relating to the Rust core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants