y
y
yq
Search…
Contains

Array contains array

Array is equal or subset of
Given a sample.yml file of:
1
- foobar
2
- foobaz
3
- blarp
Copied!
then
1
yq eval 'contains(["baz", "bar"])' sample.yml
Copied!
will output
1
true
Copied!

Object included in array

Given a sample.yml file of:
1
"foo": 12
2
"bar":
3
- 1
4
- 2
5
- "barp": 12
6
"blip": 13
Copied!
then
1
yq eval 'contains({"bar": [{"barp": 12}]})' sample.yml
Copied!
will output
1
true
Copied!

Object not included in array

Given a sample.yml file of:
1
"foo": 12
2
"bar":
3
- 1
4
- 2
5
- "barp": 12
6
"blip": 13
Copied!
then
1
yq eval 'contains({"foo": 12, "bar": [{"barp": 15}]})' sample.yml
Copied!
will output
1
false
Copied!

String contains substring

Given a sample.yml file of:
1
foobar
Copied!
then
1
yq eval 'contains("bar")' sample.yml
Copied!
will output
1
true
Copied!

String equals string

Given a sample.yml file of:
1
meow
Copied!
then
1
yq eval 'contains("meow")' sample.yml
Copied!
will output
1
true
Copied!