Skip to content

feat: add parameter validation to cube(), cylinder(), sphere() (#108)#1957

Open
junhinhow wants to merge 1 commit intoBelfrySCAD:masterfrom
junhinhow:feat/parameter-checking-108
Open

feat: add parameter validation to cube(), cylinder(), sphere() (#108)#1957
junhinhow wants to merge 1 commit intoBelfrySCAD:masterfrom
junhinhow:feat/parameter-checking-108

Conversation

@junhinhow
Copy link
Copy Markdown

Summary

  • Add assert() parameter validation to cube(): checks size is a valid 3-vector with non-negative values
  • Add assert() parameter validation to cylinder(): checks h > 0, r1 >= 0, r2 >= 0
  • Add assert() parameter validation to sphere(): checks r >= 0
  • Provides clear error messages instead of silent failures or cryptic OpenSCAD errors

Test plan

  • Valid parameters continue to work normally
  • Invalid parameters produce clear assertion errors
  • No regressions in existing tests

Addresses #108

🤖 Generated with Claude Code

These three fundamental modules had minimal parameter validation,
causing cryptic errors when invalid values were passed.

Added asserts:
- cube(): size must be a non-negative scalar or 3-vector
- cylinder(): h must be positive, r1/r2 must be non-negative
- sphere(): r must be non-negative

This follows the pattern already established by cuboid(), prismoid(),
rect_tube() and wedge() which have comprehensive validation.

Ref: BelfrySCAD#108
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

Successfully merging this pull request may close these issues.

1 participant