Меню

Yaml проверка на ошибки

Что такое YAML?

YAML (Yet Another Markup Language) или (YAML Ain’t Markup Language) является удобные для человека стандартом сериализации данных для всех языков программирования и часто используется для написания файлов конфигурации.

Об инструменте проверки YAML

Проверить YAML онлайн, также называемая YAML Lint инструментом, была создана для отладки, поиска ошибок и предупреждений в YAML файлах. Этот инструмент позволяет решить проблему путем проверки YAML данных, чтобы его можно было легко отлаживать.

Как это работает?

Просто вставьте свои YAML данные в текстовое поле выше и нажмите кнопку «Проверить», и вы получите результат проверки ниже в следующей форме.

Пример

Правильный YAML:

# test yaml -----------------------------------------------#
namespace: commontests
actor_suffix: Tester
paths:
    tests: tests
    output: tests/_output
    data: tests/_data
    support: tests/_support
settings:
    bootstrap: _bootstrap.php
    colors: true
    memory_limit: 1024M
modules:
    config:
        wtools:
            configFile: 'config/test-local.php'

YAML с ошибкой:

plain
text
is
not
yaml

We put a browser in your browser!
Browserling

Check out our project Browserling – get a browser in your browser and browse while you browse.

Pro tips
Master online yaml tools

You can pass input to this tool via

?input

query argument and it will automatically compute output. Here’s how to type it in your browser’s address bar. Click to try!

https://onlineyamltools.com/validate-yaml

?input

=plain%0Atext%0Ais%0Anot%0Ayaml

Coming soon
These yaml tools are on the way

Diff Two YAML Files

Compare two YAML files and show their differences.

Show YAML Statistics

Show detailed information about a YAML config.

Flatten YAML

Quickly flatten a nested YAML config file.

Truncate YAML

Loop over YAML and truncate lists, arrays, and strings.

Create a PHP Array from YAML

Convert YAML config to a PHP data structure.

Convert YAML to Properties

Convert a YAML file to a properties file.

Convert Properties ot YAML

Convert a properties file to a YAML file.

Convert YAML to TOML

Convert a YAML file to a TOML file.

Convert TOML to YAML

Convert a TOML config to a YAML config.

Convert YAML to NestedText

Convert a YAML file to a NestedText file.

Convert NestedText to YAML

Convert a NestedText config to a YAML config.

Convert YAML to PDF

Create a PDF file from a YAML file.

Sort YAML

Sort a YAML file by keys or by values.

Extract Keys from YAML

Find and extract all keys from a YAML file.

Extract Values from YAML

Find and extract all keys from a YAML file.

Extract Strings from YAML

Find and extract all strings from a YAML file.

Extract Numbers from YAML

Find and extract all numbers from a YAML file.

Extract Comments from YAML

Find and extract all comments from a YAML file.

Remove Comments from YAML

Clean up a YAML configuration file from comments.

Add Errors to YAML

Add tiny errors to YAML and create an invalid YAML file.

Change All Quotes to Double Quotes

Normalize all quotes in a YAML file to double quotes.

Change All Quotes to Single Quotes

Normalize all quotes in a YAML file to single quotes.

Visualize YAML Structure

Create an abstract image that represents YAML data.

YAML Validator is easy to use the YAML Validate tool. Copy, Paste, and Validate. This is also called a YAML Lint tool.

What can you do with YAML Validator Online?

  • It helps to Validate your YAML data.
  • It also works as YAML Checker or YAML syntax checker.
  • This tool allows loading the YAML URL to validate. Use your YAML REST URL to validate. Click on the Load URL button, Enter URL and Submit.
  • Users can also validate YAML Files by uploading the file. This functionality also referred to as YAML File validator
  • It helps to save your validated YAML online and Share it on social sites or emails.
  • YAML Validator works well on Windows, MAC, Linux, Chrome, Firefox, Edge, and Safari.
  • This YAML Linter helps a developer who works with JSON data to test and verify.

Example to validate YAML

Valid YAML Try it.

InsuranceCompanies: 
 Time: "May 2021"
 "Top Insurance Companies": 
  - 
   No: 1
   Name: "Berkshire Hathaway ( BRK.A)"
   "Market Capitalization": "$655 billion"
 source: "investopedia.com"
 url: "https://www.investopedia.com/articles/active-trading/111314/top-10-insurance-companies-metrics.asp"                                              

Invalid YAML Try it.

InsuranceCompanies: 
 Time: "May 2021
 "Top Insurance Companies": 
  - 
   No: 1
   Name: "Berkshire Hathaway ( BRK.A)"
   "Market Capitalization": "$655 billion"
 source: "investopedia.com"
 url: "https://www.investopedia.com/articles/active-trading/111314/top-10-insurance-companies-metrics.asp"                                               

For Advanced Users

Lua External URL

Load Lua External URL in Browser URL like this https://codebeautify.org/yaml-validator?url=external-url

https://codebeautify.org/yaml-validator?url=https://gist.githubusercontent.com/cbmgit/b4b3a9361a795e4886966b6e12abeeaf/raw/InsuranceCompanies.yaml

Text Tools

String Utilities

Case Converter

Sort Lines

Diff Checker

Text Editor

JSON Editor

Lorem Ipsum Generator

URL Parser / Query String Splitter

Slug Generator

HTML Stripper

Pastebin

Formatters

HTML Formatter / Minifier

CSS Beautifier / Minifier

JavaScript Beautifier / Minifier

JSON Formatter / Minifier

XML Formatter / Minifier

SQL Formatter / Minifier

Escape and Unescape Tools

HTML Escape / Unescape

JavaScript Escape / Unescape

JSON Escape / Unescape

XML Escape / Unescape

SQL Escape / Unescape

Validators

HTML Validator

JSON Validator

YAML Validator

Credit Card Validator

Regular Expression Tester

Cryptography and Security

Hash Generator

HMAC Generator

Checksum Calculator

Password Generator

Bcrypt Generator / Checker

UUID Generator

Encoders and Decoders

URL Encoder / Decoder

HTML Entity Encoder / Decoder

Base32 Encoder / Decoder

Base58 Encoder / Decoder

Base64 Encoder / Decoder

Base64 Image Encoder / Decoder

JWT Decoder

Converters

JavaScript / JSON Converter

CSV / JSON Converter

JSON / XML Converter

JSON / PHP Array Converter

Text / HEX Converter

Base Converter

Unit Converter

UNIX Timestamp Converter

Image Tools

Color Picker

QR Code Generator

QR Code Reader

EXIF Viewer

Network Tools

My IP

IP Lookup

IP / Number Converter

CIDR / IP Converter

WHOIS Lookup

I am having issues pulling from a YAML config file:

Fatal error: while parsing a block mapping; expected <block end>, but found block entry

While there are plenty of online YAML validators, which I have tried and have helped, I’d like to validate my YAML files from the command line and integrate this into my continuous integration pipeline.

brian d foy's user avatar

brian d foy

127k31 gold badges204 silver badges581 bronze badges

asked Oct 19, 2010 at 19:11

11

With basic Ruby installation this should work:

ruby -ryaml -e "p YAML.load(STDIN.read)" < data.yaml

Python version (thx @Murphy):

pip install pyyaml
python -c 'import yaml, sys; print(yaml.safe_load(sys.stdin))' < data.yaml

answered Dec 6, 2013 at 9:23

Tombart's user avatar

TombartTombart

29.5k15 gold badges122 silver badges131 bronze badges

8

You could use yamllint. It’s available in Homebrew, etc. It can be used for syntax validation as well as for linting.

answered Jan 16, 2020 at 20:50

James Hiew's user avatar

James HiewJames Hiew

5,4745 gold badges25 silver badges39 bronze badges

Given that you have a perl install on the server you are working on, and it has some of the basic YAML tools, you can use…

perl -MYAML -e 'use YAML;YAML::LoadFile("./file.yaml")'

It should be noted that this will be strict in it’s interpretation of the file, but useful.

answered Dec 27, 2012 at 22:58

CS Marshall's user avatar

CS MarshallCS Marshall

4014 silver badges3 bronze badges

4

To correct your .yaml files I recommend the tool yamllint. It can be launched easily from the local console.

The package yamllint is available for all major operating systems.

It’s installable from the system’s package sources. (e.g. sudo apt-get install yamllint).
See documentation for quick start and installation.

answered Mar 17, 2020 at 15:24

kinafu's user avatar

kinafukinafu

4384 silver badges5 bronze badges

1

My preferd way is
yamllint -d "{extends: default, rules: {quoted-strings: enable}}" .

Since I really want to catch quote errors,
e.g. validate: bash -c ' ' ""

This is valid yaml, since yaml will just quote the string and turn it into:
validate: "bash -c ' ' \"""

Whilst there was just clearly a quote missing at the beginning of the validate comand.

So a normal yaml checker will not detect this, yamllint wil not even detect this in it’s default configuration, so turn on quoted-strings checker.

answered May 3, 2022 at 16:25

Jens Timmerman's user avatar

Jens TimmermanJens Timmerman

8,9371 gold badge39 silver badges47 bronze badges

If you got no interpreter installed in your environment but still got a curl, then you could use an online linter project like Lint-Trilogy:

curl -X POST  --data "data=$(cat myfile.yml)" https://www.lint-trilogy.com/lint/yaml/json

It delivers the validation result incl. error descriptions (if any) as json or csv or, where sufficient, as plain text true or false.

It’s available as docker file, too. So if you often need a REST based linter, perhaps in a CI/CD pipeline, it may be handy to host an own instance on your site.

answered Nov 26, 2020 at 17:09

Doc's user avatar

3

Or alternately installed (free) Eclipse IDE and then YEdit yaml editor and see your yaml with syntax highlighting, error flags, and outline views. One time setup cost works pretty well for me.

answered Dec 9, 2013 at 16:55

Ernie's user avatar

ErnieErnie

371 silver badge1 bronze badge

1

0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии

А вот еще интересные материалы:

  • Яшка сломя голову остановился исправьте ошибки
  • Ясность цели позволяет целеустремленно добиваться намеченного исправьте ошибки
  • Ясность цели позволяет целеустремленно добиваться намеченного где ошибка
  • Windows 10 pro код ошибки 0x8007232b
  • Xerox 7120 ошибка 092 314