# Validate

## Description

This command allows you validate files.

It will not modify the source data in any way.

{% hint style="info" %}
Available since `v1.25.0.`
{% endhint %}

## Usage

```shell
dasel validate a.json b.yaml files/*.json
```

### Flags

| `--include-error` | <p>Tells dasel to output to include/exclude the error when a file fails validation.<br><br>Default to <code>true</code>.</p> |
| ----------------- | ---------------------------------------------------------------------------------------------------------------------------- |

## Example

### Validate an entire directory

```shell
$ dasel validate tests/assets/*
fail tests/assets/broken.json could not load input: could not unmarshal data: invalid character '}' after array element
fail tests/assets/broken.xml could not load input: could not unmarshal data: xml.Decoder.Token() - XML syntax error on line 1: element <a> closed by </b>
pass tests/assets/deployment.yaml
pass tests/assets/example.json
pass tests/assets/example.xml
pass tests/assets/example.yaml
Error: 2 files failed validation
```

### Validate a subset of files

```shell
$ dasel validate tests/assets/example.*
pass tests/assets/example.json
pass tests/assets/example.xml
pass tests/assets/example.yaml
```

### Validate specific files

```shell
$ dasel validate tests/assets/example.json tests/assets/example.yaml
pass tests/assets/example.json
pass tests/assets/example.yaml
```

## Pre-Commit

Add `dasel` hooks to `.pre-commit-config.yaml` file

```yaml
- repo: https://github.com/TomWright/dasel
  rev: v1.25.1
  hooks:
    - id: dasel-validate
```

for a native execution of dasel, or use:

* `dasel-validate-docker` pre-commit hook for executing dasel using the official [Docker images](https://daseldocs.tomwright.me/installation#docker)
* `dasel-validate-bin` pre-commit hook for executing dasel using the official [binary](https://github.com/TomWright/dasel-docs/blob/master/usage/installation/README.md)


---

# 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://daseldocs.tomwright.me/v1/usage/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.
