Test-OfficeToml
Tests whether TOML files or text load, without changing them.
Syntax
Test-OfficeToml
[-Detailed]
[-Path] <String[]>
[-Untrusted]
[<CommonParameters>]#PathTest-OfficeToml
[-Detailed]
-LiteralPath <String[]>
[-Untrusted]
[<CommonParameters>]#LiteralPathTest-OfficeToml
[-Detailed]
-Text <String>
[-Untrusted]
[<CommonParameters>]#TextDescription
Returns $true or $false for each input, as Test-Json does. Detailed returns a result with the error's diagnostic code, message, and 1-based line and column. Loading checks all of TOML 1.1, including duplicate keys and the rules for defining tables; Untrusted applies the engine's limits for files from outside.
Examples
Gate a pipeline step on a valid file.
if (-not (Test-OfficeToml -Path ./pyproject.toml)) { throw 'pyproject.toml is not valid TOML.' }Report where every broken file fails.
Get-ChildItem ./crates -Recurse -Filter *.toml | Test-OfficeToml -Detailed |
Where-Object { -not $_.IsValid } |
Select-Object -Property Path, Line, Column, Code, MessageParameters
- -Detailed SwitchParameter
- Return a result with the error code and position instead of a Boolean.
- -Path String[]
- TOML files with FileSystem wildcard expansion.
- -Untrusted SwitchParameter
- Caps every limit at the engine's untrusted defaults, for files from outside.
- -LiteralPath String[]
- Literal TOML files, including FileInfo.FullName and provider PSPath.
- -Text String
- TOML text to test.
Common Parameters
This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
For more information, see about_CommonParameters.
Outputs
PSWriteOffice.Models.Toml.OfficeTomlTestResult: The outcome of Test-OfficeToml -Detailed for one input.