Specifying the string-value ‘Yes’ in YAML

It depends 😉

In YAML 1.1 the bool type is defined as following:

A Boolean represents a true/false value. Booleans are formatted as English words (“true”/“false”, “yes”/“no” or “on”/“off”) for readability and may be abbreviated as a single character “y”/“n” or “Y”/“N”.

The regexp the parser should use is

y|Y|yes|Yes|YES|n|N|no|No|NO|
true|True|TRUE|false|False|FALSE|
on|On|ON|off|Off|OFF

In YAML 1.2.2 the bool type is defined as following:

Booleans: [ true, false ]

Assigning the value Yes to a key is done via quotes:

foo: 'Yes'
bar: "Yes"

Assigning a boolean and to be compatible with future versions of YAML parsers should be done with

foo: false
bar: true

Many YAML 1.2 compatible parsers still accept the 1.1 specification for booleans.

Leave a Comment