Skip to content

Commit

Permalink
Added is_type function
Browse files Browse the repository at this point in the history
Signed-off-by: Victor Moene <[email protected]>
  • Loading branch information
victormlg committed Feb 6, 2025
1 parent ab1bc57 commit 5659a0f
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions reference/functions/is_type.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
layout: default
title: type
published: true
---

[%CFEngine_function_prototype(var, type)%]

**Description:** Returns whether a variable `var` is of type `type`

[%CFEngine_function_attributes(var, type)%]

This function works by comparing the type description of `var` with the string `type`. The function
expects a variable identifier as the first argument `var` and a type string as
the second argument `type`. The type accepts both the type and an optional subtype. The function
by default evaluates to false if the variable or the type string are wrong.

To see the possible data types and theit subtypes, see `type()`

**Example:**

[%CFEngine_include_snippet(is_type.cf, #\+begin_src cfengine3, .*end_src)%]

Output:

[%CFEngine_include_snippet(is_type.cf, #\+begin_src\s+example_output\s*, .*end_src)%]

**History:**

* Introduced in 3.26.0

0 comments on commit 5659a0f

Please sign in to comment.