# Validate

```
yq v <yaml_file|->
```

Validates the given yaml file, does nothing if its valid, otherwise it will print errors to Stderr and exit with a non 0 exit code. This works like the [read command](/yq/v3.x/commands/read.md) - but does not take a path expression and does not print the yaml if it is valid.

## Basic - valid

```
yq v valid.yaml
```

This will not print anything, and finish with a successful (0) exit code.

## Basic - invalid, from stdin

```
echo '[1234' | yq v -
```

This will print the parsing error to stderr:

```bash
﻿﻿10:43:09 main [ERRO] yaml: line 1: did not find expected ',' or ']'
```

And return a error exit code (1)

## Multiple documents

Like other commands, by default the validate command will only run against the first document in the yaml file. Note that when running against other specific document indexes, *all previous documents will also be validated.*

### Validating a single document

```bash
yq v -d1 multidoc.yml
```

This will validate both document 0 and document 1 (but not document 2)

### Validating all documents

```bash
yq v -d'*' multidoc.yml
```

This will validate all documents in the yaml file. Note that \* is quoted to avoid the CLI from processing the wildcard.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mikefarah.gitbook.io/yq/v3.x/commands/validate.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
