Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

Test-OfficeToml

Module
PSWriteOffice
Inputs
System.String[]
Outputs
System.Boolean PSWriteOffice.Models.Toml.OfficeTomlTestResult

Tests whether TOML files or text load, without changing them.

Syntax

Test-OfficeToml
[-Detailed]
[-Path] <String[]>
[-Untrusted]
[<CommonParameters>]
#
Parameter set: Path
Test-OfficeToml
[-Detailed]
-LiteralPath <String[]>
[-Untrusted]
[<CommonParameters>]
#
Parameter set: LiteralPath
Test-OfficeToml
[-Detailed]
-Text <String>
[-Untrusted]
[<CommonParameters>]
#
Parameter set: Text

Description

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, Message

Parameters

-Detailed SwitchParameter optional
Return a result with the error code and position instead of a Boolean.
-Path String[] requiredposition: 0pipeline: True (ByValue)sets: Path
TOML files with FileSystem wildcard expansion.
-Untrusted SwitchParameter optional
Caps every limit at the engine's untrusted defaults, for files from outside.
-LiteralPath String[] requiredpipeline: True (ByPropertyName)aliases: FullName, PSPathsets: LiteralPath
Literal TOML files, including FileInfo.FullName and provider PSPath.
-Text String requiredsets: Text
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.