summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorDave Henderson <dhenderson@gmail.com>2024-06-16 15:16:54 -0400
committerGitHub <noreply@github.com>2024-06-16 19:16:54 +0000
commitc275254c45353aeadf6adf85858856d0c36d624f (patch)
treee64ac9cef3f839fc7a38077bc98e26115a3803b5 /docs
parenta33f6d9fe0f145afdd06ef5b3431e3c2fe281c16 (diff)
chore(api)!: Error instead of returning 0 on invalid inputs to conv.* functions (#2104)
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'docs')
-rw-r--r--docs/content/functions/conv.md18
1 files changed, 14 insertions, 4 deletions
diff --git a/docs/content/functions/conv.md b/docs/content/functions/conv.md
index 779d2133..904efb2f 100644
--- a/docs/content/functions/conv.md
+++ b/docs/content/functions/conv.md
@@ -453,8 +453,9 @@ Converts the input to an `int64` (64-bit signed integer).
This function attempts to convert most types of input (strings, numbers,
and booleans), but behaviour when the input can not be converted is
-undefined and subject to change. Unconvertable inputs may result in
-errors, or `0` or `-1`.
+undefined and subject to change.
+
+Unconvertable inputs will result in errors.
Floating-point numbers (with decimal points) are truncated.
@@ -493,6 +494,8 @@ on platform). This is similar to [`conv.ToInt64`](#conv-toint64) on 64-bit
platforms, but is useful when input to another function must be provided
as an `int`.
+Unconvertable inputs will result in errors.
+
On 32-bit systems, given a number that is too large to fit in an `int`,
the result is `-1`. This is done to protect against
[CWE-190](https://cwe.mitre.org/data/definitions/190.html) and
@@ -532,6 +535,8 @@ $ gomplate -i '{{conv.ToInt true }}'
Converts the inputs to an array of `int64`s.
+Unconvertable inputs will result in errors.
+
This delegates to [`conv.ToInt64`](#conv-toint64) for each input argument.
_Added in gomplate [v2.2.0](https://github.com/hairyhenderson/gomplate/releases/tag/v2.2.0)_
@@ -558,6 +563,8 @@ gomplate -i '{{ conv.ToInt64s true 0x42 "123,456.99" "1.2345e+3"}}'
Converts the inputs to an array of `int`s.
+Unconvertable inputs will result in errors.
+
This delegates to [`conv.ToInt`](#conv-toint) for each input argument.
_Added in gomplate [v2.2.0](https://github.com/hairyhenderson/gomplate/releases/tag/v2.2.0)_
@@ -586,8 +593,9 @@ Converts the input to a `float64`.
This function attempts to convert most types of input (strings, numbers,
and booleans), but behaviour when the input can not be converted is
-undefined and subject to change. Unconvertable inputs may result in
-errors, or `0` or `-1`.
+undefined and subject to change.
+
+Unconvertable inputs will result in errors.
_Added in gomplate [v2.2.0](https://github.com/hairyhenderson/gomplate/releases/tag/v2.2.0)_
### Usage
@@ -615,6 +623,8 @@ $ gomplate -i '{{ conv.ToFloat64 "9,000.09"}}'
Converts the inputs to an array of `float64`s.
+Unconvertable inputs will result in errors.
+
This delegates to [`conv.ToFloat64`](#conv-tofloat64) for each input argument.
_Added in gomplate [v2.2.0](https://github.com/hairyhenderson/gomplate/releases/tag/v2.2.0)_