Scripts that load TOML content from external sources need to validate it before parsing. Once ConvertFrom-Toml lands (#2), the only signal of invalid input will be a thrown exception. PowerShell's Test-Json sets the established pattern for serialization-format validators: returns [bool], writes parser errors to the error stream when invalid.
Request
Desired capability
Test-Toml -Path Cargo.toml # validate a file
$content | Test-Toml # validate a string
'[invalid' | Test-Toml # returns $false, writes error
Parameters
| Parameter |
Description |
-Path |
File path to validate (parameter set: Path) |
-LiteralPath |
Literal path (parameter set: LiteralPath) |
-InputObject |
String to validate (ValueFromPipeline, default set) |
Acceptance criteria
Technical decisions
Implementation: Wraps ConvertFrom-Toml in try/catch. On exception, writes the parser error via Write-Error and returns $false. On success, returns $true.
Function placement: src/functions/public/Test-Toml.ps1.
No new parser logic: Reuses the existing ConvertFrom-Toml parser. This keeps validation behavior consistent with parsing behavior.
Output type: [bool] only — never throws on invalid input.
Alias: Test-Tml, matching the planned alias pattern in #2.
Implementation plan
Related
Scripts that load TOML content from external sources need to validate it before parsing. Once
ConvertFrom-Tomllands (#2), the only signal of invalid input will be a thrown exception. PowerShell'sTest-Jsonsets the established pattern for serialization-format validators: returns[bool], writes parser errors to the error stream when invalid.Request
Desired capability
Parameters
-PathPath)-LiteralPathLiteralPath)-InputObjectValueFromPipeline, default set)Acceptance criteria
$truewhen content is valid TOML 1.0 (or 1.1, depending on parser scope from Add ConvertFrom-Toml and ConvertTo-Toml functions with full TOML v1.1.0 spec coverage #2)$falsewhen content is invalid; the parser error is written to the error streamTest-Jsonparameter shape and behaviorTechnical decisions
Implementation: Wraps
ConvertFrom-Tomlintry/catch. On exception, writes the parser error viaWrite-Errorand returns$false. On success, returns$true.Function placement:
src/functions/public/Test-Toml.ps1.No new parser logic: Reuses the existing
ConvertFrom-Tomlparser. This keeps validation behavior consistent with parsing behavior.Output type:
[bool]only — never throws on invalid input.Alias:
Test-Tml, matching the planned alias pattern in #2.Implementation plan
Test-Tomlinsrc/functions/public/Test-Toml.ps1withTest-TmlaliasRelated
ConvertFrom-Toml(prerequisite)