Skip to content

Commit e6515eb

Browse files
authored
Merge pull request #3748 from victormlg/validfiledata
ENT-8193: Added docs entry for validfiledata
2 parents 440f117 + a1ea0ee commit e6515eb

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
layout: default
3+
title: validfiledata
4+
aliases:
5+
- "/reference-functions-validfiledata.html"
6+
---
7+
8+
{{< CFEngine_function_prototype(filename, filetype) >}}
9+
10+
**Description:** Parses CSV, JSON, or YAML data from file `filename`
11+
and returns `true` if the content is valid and `false` otherwise.
12+
13+
When `filetype` is `auto`, the file type is inferred from the extension
14+
(ignoring case): `.csv` means CSV; `.json` means JSON; `.yaml` or `.yml` means
15+
YAML. If the file doesn't match any of those names, JSON is used.
16+
17+
{{< CFEngine_function_attributes(filename, filetype) >}}
18+
19+
**Example:**
20+
21+
```cf3
22+
bundle agent main
23+
{
24+
vars:
25+
"content"
26+
data => readdata("/tmp/a.json", "auto"),
27+
if => validfiledata("/tmp/a.json", "auto");
28+
}
29+
```
30+
31+
**See also:** [`data_expand()`][data_expand], `readdata()`, `readcsv()`, `readyaml()`, `readjson()`, `readenvfile()`, `validdata()`, `data` documentation.
32+
33+
**History:** Was introduced in 3.29.0.

0 commit comments

Comments
 (0)