Skip to content

Commit 2dad06b

Browse files
committed
Added docs entry for validfiledata
Changelog: None Ticket: ENT-8193 Signed-off-by: Victor Moene <victor.moene@northern.tech>
1 parent 440f117 commit 2dad06b

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 guessed 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)