Skip to content

style: add ValidateNotNullOrEmpty to ManifestHelpers mandatory string params#8

Merged
tablackburn merged 1 commit into
mainfrom
style/manifesthelpers-validators
May 12, 2026
Merged

style: add ValidateNotNullOrEmpty to ManifestHelpers mandatory string params#8
tablackburn merged 1 commit into
mainfrom
style/manifesthelpers-validators

Conversation

@tablackburn
Copy link
Copy Markdown
Owner

@tablackburn tablackburn commented May 12, 2026

Summary

Completes the tests/ManifestHelpers.psm1 validator alignment with the canonical PowerShellModuleTemplate#23. PR #7 added [ValidateNotNullOrEmpty()] to Split-SemVerString -VersionString; this PR covers the remaining six mandatory [string] parameters:

Function Parameter
Compare-SemVerPrerelease $FirstPrerelease
Compare-SemVerPrerelease $SecondPrerelease
Test-VersionComparison $FirstVersion
Test-VersionComparison $SecondVersion
Test-VersionConstraint $ManifestVersion
Test-VersionConstraint $RequirementsVersion

$Constraint already has [ValidateSet] and the two $*Prerelease params on Test-VersionComparison keep 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]::IsNullOrWhiteSpace guards on Test-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-SemVerString calls inside Test-VersionConstraint and the quoted-literal cleanup on the two throw strings are separate items not bundled here — they'll be a follow-up in line with how PR #7 was kept tight.

Test plan

  • CI passes on Linux / macOS / Windows runners (Manifest.tests.ps1 exercises these helpers against the real JsmOperations.psd1 and requirements.psd1).
  • ./build.ps1 locally — no new validation errors.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Strengthened parameter validation for version constraint testing to reject null or empty version strings at the validation stage, preventing invalid inputs from being processed and improving error handling.

Review Change Stack

… 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.
Copilot AI review requested due to automatic review settings May 12, 2026 02:54
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 12, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e056ff60-50be-4022-a9af-fc45ba6f6f8a

📥 Commits

Reviewing files that changed from the base of the PR and between c8f8339 and f0ca200.

📒 Files selected for processing (1)
  • tests/ManifestHelpers.psm1

📝 Walkthrough

Walkthrough

Parameter validation is tightened across three SemVer comparison helper functions by adding ValidateNotNullOrEmpty attributes to version and prerelease parameters, preventing empty or null strings from entering the parsing logic.

Changes

SemVer Helper Parameter Validation

Layer / File(s) Summary
Tighten version and prerelease parameter validation
tests/ManifestHelpers.psm1
Compare-SemVerPrerelease, Test-VersionComparison, and Test-VersionConstraint all add ValidateNotNullOrEmpty validation to their version and prerelease parameters, rejecting empty inputs during parameter binding before SemVer parsing.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

Poem

🐰 A rabbit's ode to tighter checks:
Guard the gates with ValidateNotNull,
Let no empty string slip through the spell,
SemVer versions now stand tall,
Parameter validation for all!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding ValidateNotNullOrEmpty validators to mandatory string parameters in ManifestHelpers.psm1.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch style/manifesthelpers-validators

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 in Compare-SemVerPrerelease.
  • Added [ValidateNotNullOrEmpty()] to mandatory version string parameters in Test-VersionComparison.
  • Added [ValidateNotNullOrEmpty()] to mandatory version string parameters in Test-VersionConstraint.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/ManifestHelpers.psm1
Comment thread tests/ManifestHelpers.psm1
@tablackburn tablackburn merged commit baa8b71 into main May 12, 2026
15 checks passed
@tablackburn tablackburn deleted the style/manifesthelpers-validators branch May 12, 2026 03:01
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.

2 participants