Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions content/reference/functions/validfiledata.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
layout: default
title: validfiledata
aliases:
- "/reference-functions-validfiledata.html"
---

{{< CFEngine_function_prototype(filename, filetype) >}}

**Description:** Parses CSV, JSON, or YAML data from file `filename`
and returns `true` if the content is valid and `false` otherwise.

When `filetype` is `auto`, the file type is guessed from the extension
(ignoring case): `.csv` means CSV; `.json` means JSON; `.yaml` or `.yml` means
YAML. If the file doesn't match any of those names, JSON is used.

{{< CFEngine_function_attributes(filename, filetype) >}}

**Example:**

```cf3
bundle agent main
{
vars:
"content"
data => readdata("/tmp/a.json", "auto"),
if => validfiledata("/tmp/a.json", "auto");
}
```

**See also:** [`data_expand()`][data_expand], `readdata()`, `readcsv()`, `readyaml()`, `readjson()`, `readenvfile()`, `validdata()`, `data` documentation.

**History:** Was introduced in 3.29.0.
Loading