style: add ValidateNotNullOrEmpty to ManifestHelpers mandatory string params#8
Conversation
… params Completes the cross-repo validator alignment with PowerShellModuleTemplate#23. PR #7 (2026-05-10) added the validator to `Split-SemVerString -VersionString`; this commit covers the remaining six mandatory `[string]` parameters across `Compare-SemVerPrerelease`, `Test-VersionComparison`, and `Test-VersionConstraint`. Behavior for valid inputs is unchanged. Misuse (null or empty version/prerelease strings) now fails at parameter binding instead of producing downstream NullReferenceExceptions inside the comparison logic.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughParameter validation is tightened across three SemVer comparison helper functions by adding ChangesSemVer Helper Parameter Validation
Estimated code review effort🎯 2 (Simple) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Aligns tests/ManifestHelpers.psm1 parameter validation with the canonical PowerShellModuleTemplate behavior by enforcing non-null/non-empty contracts at parameter binding time for mandatory string inputs, reducing downstream runtime exceptions in SemVer comparison logic.
Changes:
- Added
[ValidateNotNullOrEmpty()]to mandatory prerelease string parameters inCompare-SemVerPrerelease. - Added
[ValidateNotNullOrEmpty()]to mandatory version string parameters inTest-VersionComparison. - Added
[ValidateNotNullOrEmpty()]to mandatory version string parameters inTest-VersionConstraint.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Completes the
tests/ManifestHelpers.psm1validator alignment with the canonical PowerShellModuleTemplate#23. PR #7 added[ValidateNotNullOrEmpty()]toSplit-SemVerString -VersionString; this PR covers the remaining six mandatory[string]parameters:Compare-SemVerPrerelease$FirstPrereleaseCompare-SemVerPrerelease$SecondPrereleaseTest-VersionComparison$FirstVersionTest-VersionComparison$SecondVersionTest-VersionConstraint$ManifestVersionTest-VersionConstraint$RequirementsVersion$Constraintalready has[ValidateSet]and the two$*Prereleaseparams onTest-VersionComparisonkeep their[AllowNull()]because they are intentionally nullable when comparing release versions.Why
Behavior for valid inputs is unchanged. Misuse (null or empty version/prerelease strings) now fails at parameter binding rather than producing downstream
NullReferenceExceptions inside the comparison logic.Out of scope
The in-body
[string]::IsNullOrWhiteSpaceguards onTest-VersionConstraint(lines 336-341) are kept as-is —[ValidateNotNullOrEmpty()]catches null/empty but not whitespace, so those guards still carry their weight. Same shape as PSMTplt#23.Named-parameter conversion on the two
Split-SemVerStringcalls insideTest-VersionConstraintand the quoted-literal cleanup on the twothrowstrings are separate items not bundled here — they'll be a follow-up in line with how PR #7 was kept tight.Test plan
Manifest.tests.ps1exercises these helpers against the realJsmOperations.psd1andrequirements.psd1)../build.ps1locally — no new validation errors.🤖 Generated with Claude Code
Summary by CodeRabbit