Test-OfficeYaml
Tests whether YAML files or text load, without changing them.
Syntax
Test-OfficeYaml
[-Detailed]
[-Options <YamlLoadOptions>]
[-Path] <String[]>
[-Schema <Failsafe| Json| Core| Yaml11>]
[-Strict]
[-Untrusted]
[<CommonParameters>]#PathTest-OfficeYaml
[-Detailed]
-LiteralPath <String[]>
[-Options <YamlLoadOptions>]
[-Schema <Failsafe| Json| Core| Yaml11>]
[-Strict]
[-Untrusted]
[<CommonParameters>]#LiteralPathTest-OfficeYaml
[-Detailed]
[-Options <YamlLoadOptions>]
[-Schema <Failsafe| Json| Core| Yaml11>]
[-Strict]
-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, 1-based line and column, and the warnings the engine recorded while loading. Strict applies the specification's exact rules, and Untrusted the engine's limits for files from outside.
Examples
Gate a pipeline step on a valid file.
if (-not (Test-OfficeYaml -Path ./values.yaml -Strict)) { throw 'values.yaml is not valid YAML.' }Report where every broken file fails.
Get-ChildItem ./deploy -Recurse -Filter *.yaml | Test-OfficeYaml -Detailed |
Where-Object { -not $_.IsValid } |
Select-Object -Property Path, Line, Column, Code, MessageParameters
- -Detailed SwitchParameter
- Return a result with the error position and the load warnings instead of a Boolean.
- -Options YamlLoadOptions
- Native load options or a hashtable of their properties.
- -Path String[]
- YAML files with FileSystem wildcard expansion.
- -Schema YamlSchema
- Forces a schema: Failsafe, Json, Core (the default) or Yaml11.
- Possible values:
Failsafe,Json,Core,Yaml11 - -Strict SwitchParameter
- Applies the YAML specification's exact rules instead of accepting common real-world leniencies.
- -Untrusted SwitchParameter
- Caps every limit at the engine's untrusted defaults.
- -LiteralPath String[]
- Literal YAML files, including FileInfo.FullName and provider PSPath.
- -Text String
- YAML 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.Yaml.OfficeYamlTestResult: The outcome of Test-OfficeYaml -Detailed for one input.