Skip to content

Test-Yaml

SYNOPSIS

Tests whether text is a valid, safely processable YAML stream.

SYNTAX

__AllParameterSets

powershell Test-Yaml [-Yaml] <string[]> [-Depth <int>] [-MaxNodes <int>] [-MaxAliases <int>] [-MaxScalarLength <int>] [-MaxTagLength <int>] [-MaxTotalTagLength <int>] [-MaxNumericLength <int>]

ALIASES

This cmdlet has the following aliases, {{Insert list of aliases}}

DESCRIPTION

Parses a YAML stream, checks unique mapping keys, validates standard tags, and applies the same resource limits as ConvertFrom-Yaml. It returns false only for module-classified YAML failures. Unexpected runtime failures are not swallowed.

Pipeline strings are joined with a line feed and tested as one stream.

EXAMPLES

EXAMPLE 1

'name: Ada' | Test-Yaml

Returns true.

PARAMETERS

-Depth

Cap YAML node nesting depth so hostile input can't exhaust the stack.

yaml Type: System.Int32 DefaultValue: 100 SupportsWildcards: false Aliases: [] ParameterSets: - Name: (All) Position: Named IsRequired: false ValueFromPipeline: false ValueFromPipelineByPropertyName: false ValueFromRemainingArguments: false DontShow: false AcceptedValues: [] HelpMessage: ''

-MaxAliases

Cap alias nodes to prevent alias-expansion amplification.

yaml Type: System.Int32 DefaultValue: 1000 SupportsWildcards: false Aliases: [] ParameterSets: - Name: (All) Position: Named IsRequired: false ValueFromPipeline: false ValueFromPipelineByPropertyName: false ValueFromRemainingArguments: false DontShow: false AcceptedValues: [] HelpMessage: ''

-MaxNodes

Cap the total node count to bound memory for a single stream.

yaml Type: System.Int32 DefaultValue: 100000 SupportsWildcards: false Aliases: [] ParameterSets: - Name: (All) Position: Named IsRequired: false ValueFromPipeline: false ValueFromPipelineByPropertyName: false ValueFromRemainingArguments: false DontShow: false AcceptedValues: [] HelpMessage: ''

-MaxNumericLength

Cap the digit count of a constructed number.

yaml Type: System.Int32 DefaultValue: 4096 SupportsWildcards: false Aliases: [] ParameterSets: - Name: (All) Position: Named IsRequired: false ValueFromPipeline: false ValueFromPipelineByPropertyName: false ValueFromRemainingArguments: false DontShow: false AcceptedValues: [] HelpMessage: ''

-MaxScalarLength

Cap decoded characters per scalar to bound per-node memory.

yaml Type: System.Int32 DefaultValue: 1048576 SupportsWildcards: false Aliases: [] ParameterSets: - Name: (All) Position: Named IsRequired: false ValueFromPipeline: false ValueFromPipelineByPropertyName: false ValueFromRemainingArguments: false DontShow: false AcceptedValues: [] HelpMessage: ''

-MaxTagLength

Cap expanded characters for a single tag.

yaml Type: System.Int32 DefaultValue: 1024 SupportsWildcards: false Aliases: [] ParameterSets: - Name: (All) Position: Named IsRequired: false ValueFromPipeline: false ValueFromPipelineByPropertyName: false ValueFromRemainingArguments: false DontShow: false AcceptedValues: [] HelpMessage: ''

-MaxTotalTagLength

Cap cumulative expanded tag characters across the stream.

yaml Type: System.Int32 DefaultValue: 65536 SupportsWildcards: false Aliases: [] ParameterSets: - Name: (All) Position: Named IsRequired: false ValueFromPipeline: false ValueFromPipelineByPropertyName: false ValueFromRemainingArguments: false DontShow: false AcceptedValues: [] HelpMessage: ''

-Yaml

The YAML text to test. Multiple pipeline records are joined with a line feed and tested as a single stream.

yaml Type: System.String[] DefaultValue: '' SupportsWildcards: false Aliases: [] ParameterSets: - Name: (All) Position: 0 IsRequired: true ValueFromPipeline: true ValueFromPipelineByPropertyName: false ValueFromRemainingArguments: false DontShow: false AcceptedValues: [] HelpMessage: ''

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

System.String[]

The YAML text to test. Multiple pipeline records are joined with a line feed.

{{ Fill in the Description }}

System.String[]

{{ Fill in the Description }}

OUTPUTS

System.Boolean

True when the stream parses within limits; false for a classified YAML failure.

{{ Fill in the Description }}

System.Boolean

{{ Fill in the Description }}

NOTES