📄
Dasel
v1
v1
  • Introduction
  • Installation
    • Update
  • Use as a go package
  • Github
  • Playground
  • Usage
    • Select
    • Put
    • Put object
    • Put document
    • Delete
    • Validate
    • Flags
      • Escape HTML
      • Format
      • Multiple
      • Null
      • Merge Input Documents
    • Supported file types
  • Selectors
    • Introduction
    • Property
    • Keys and indexes
    • Index
    • Next Available Index
    • All indexes
    • Dynamic
    • Search
    • Search Optional
    • Length
    • Type
  • Notes
    • File formatting and ordering
    • Memory usage
    • Converting between formats
  • Examples
    • JQ to Dasel
    • YQ to Dasel
    • XML
    • Filter JSON API results
Powered by GitBook
On this page
  • Description
  • Usage
  • Flags
  • Example
  • Validate an entire directory
  • Validate a subset of files
  • Validate specific files
  • Pre-Commit
Edit on GitHub
  1. Usage

Validate

Description

This command allows you validate files.

It will not modify the source data in any way.

Available since v1.25.0.

Usage

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

Flags

--include-error

Tells dasel to output to include/exclude the error when a file fails validation. Default to true.

Example

Validate an entire directory

$ 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

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

Validate specific files

$ 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

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

for a native execution of dasel, or use:

PreviousDeleteNextFlags

Last updated 2 years ago

dasel-validate-docker pre-commit hook for executing dasel using the official

dasel-validate-bin pre-commit hook for executing dasel using the official

Docker images
binary