🩹 [Patch]: Add Test-Toml to validate TOML without throwing - #22
Merged
Marius Storhaug (MariusStorhaug) merged 3 commits intoJul 26, 2026
Merged
Conversation
Implement Test-Toml that validates TOML content without throwing. Mirrors PowerShell's Test-Json pattern: - Returns [bool] -- $true for valid, $false for invalid - Writes non-terminating errors via Write-Error on failure - Supports InputObject (pipeline), Path, and LiteralPath parameter sets - Uses [AllowEmptyString()] so empty string returns $false gracefully Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Add Describe 'Test-Toml' block covering: - Module registration and [OutputType([bool])] declaration - Valid TOML string, [bool] return type, pipeline input - Invalid TOML: returns $false and non-terminating error - Empty string: returns $false - Duplicate-key document: returns $false - -Path: valid file returns $true, invalid returns $false, non-existent file returns $false and error - -LiteralPath: valid file returns $true and [bool] type Also update module-level 'exposes the expected public commands' test to include 'Test-Toml'. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Marius Storhaug (MariusStorhaug)
marked this pull request as ready for review
July 26, 2026 07:52
Marius Storhaug (MariusStorhaug)
force-pushed
the
feat-test-toml
branch
from
July 26, 2026 07:52
253ff1b to
f47540d
Compare
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds
Test-Toml, a pure-validator that returns[bool]— never throws — so scripts can safely probe TOML content before (or instead of) parsing it. The design mirrors PowerShell's built-inTest-Json.New: Validate TOML content safely
Test-TomlwrapsConvertFrom-Tomlin a try/catch. On success it returns$true; on any parser error it writes a non-terminating error to the error stream and returns$false.Parameter sets
-InputObject[AllowEmptyString()]so''returns$false-PathPath-LiteralPathLiteralPathKey implementation notes
[AllowEmptyString()]is required onInputObject: PowerShell's mandatory parameter binding rejects''without it, whereas the correct behaviour is$false.Write-Erroris always called from inside acatchblock with-ErrorAction Continueto ensure non-terminating behaviour even when$ErrorActionPreference = 'Stop'is set module-wide.ConvertFrom-Tomlto keep validation consistent with parsing.Technical Details
src/functions/public/Test-Toml.ps1Describe 'Test-Toml'block intests/Toml.Tests.ps1(11 new tests; total 135, all passing)Test-Tmlbut aliases are not in the current module standardsDetails
Closes #4