Added docs on yes/no being strings in yaml spec 1.2

This commit is contained in:
Mike Farah
2023-05-23 15:35:39 +10:00
parent 5ef537f3fd
commit 5950329e2c
3 changed files with 29 additions and 0 deletions
@@ -26,6 +26,24 @@ will output
true
```
## "yes" and "no" are strings
In the yaml 1.2 standard, support for yes/no as booleans was dropped - they are now considered strings. See '10.2.1.2. Boolean' in https://yaml.org/spec/1.2.2/
Given a sample.yml file of:
```yaml
- yes
- no
```
then
```bash
yq '.[] | tag' sample.yml
```
will output
```yaml
!!str
!!str
```
## `and` example
Running
```bash
+10
View File
@@ -12,6 +12,16 @@ var booleanOperatorScenarios = []expressionScenario{
"D0, P[], (!!bool)::true\n",
},
},
{
description: "\"yes\" and \"no\" are strings",
subdescription: "In the yaml 1.2 standard, support for yes/no as booleans was dropped - they are now considered strings. See '10.2.1.2. Boolean' in https://yaml.org/spec/1.2.2/",
document: `[yes, no]`,
expression: `.[] | tag`,
expected: []string{
"D0, P[0], (!!str)::!!str\n",
"D0, P[1], (!!str)::!!str\n",
},
},
{
skipDoc: true,
document: "b: hi",