From fee4caf2f9adc7f5f9bb1b79c512d22c1f45cd0d Mon Sep 17 00:00:00 2001 From: Thomas Heartman Date: Tue, 8 Mar 2022 13:44:02 +0100 Subject: [PATCH] docs: Add note about how invalid context field values are handled --- website/docs/advanced/strategy-constraints.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/website/docs/advanced/strategy-constraints.md b/website/docs/advanced/strategy-constraints.md index cd6e7815d4..0311783f60 100644 --- a/website/docs/advanced/strategy-constraints.md +++ b/website/docs/advanced/strategy-constraints.md @@ -68,9 +68,9 @@ In this section, `` is used as a placeholder for an arbitrary con Unleash currently supports 15 different constraint operators. The operators can be grouped into four different categories based on their method of comparison. -### Constraint negation / inversion +### Constraint negation / inversion {#constraint-negation} -All operators can be **negated**, meaning that they get their opposite value. Constraints are evaluated to either `true` or `false`. Negating an operator would turn a `true` value into a `false` and a `false` value into a `true` value. +All constraint expressions can be **negated**, meaning that they get their opposite value. Constraints are evaluated to either `true` or `false`. Negating a constraint would turn a `true` value into a `false` and a `false` value into a `true` value. For instance, using the numeric equivalence operator `NUM_EQ`, the following truth table shows the how value negation affects the result: @@ -165,6 +165,12 @@ If the strategy constraint uses a [**standard Unleash Context field**](../user_g If the strategy constraint uses a [**custom context field**](../user_guide/unleash_context#custom-context-fields), use the Unleash Context's `properties` field. Use the name of the custom context field as a key and set the value to your desired string. +If you set a context field to a value that the SDKs cannot parse correctly for a chosen constraint operator, the strategy constraint will evaluate to false. +In other words: if you have a strategy constraint operator that expects a number, such as `NUM_GT`, but you set the corresponding context field to a string value, then the expression will be false: `"some string"` is **not** greater than `5`. +This value can still be negated as explained in [the section on negating values](#constraint-negation). + + + ## [Deprecated]: Constrain on a specific environment {#constrain-on-a-specific-environment} Before Unleash 4.3, using strategy constraints was the recommended way to have different toggle configurations per environment. Now that Unleash has environment support built in, we no longer recommend you use strategy constraints for this. Instead, see the [environments documentation](../user_guide/environments).