diff --git a/mkdocs.yml b/mkdocs.yml index 99a6d1d28..10a4ac79c 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -39,6 +39,7 @@ markdown_extensions: - name: mermaid class: mermaid format: !!python/name:pymdownx.superfences.fence_code_format + - tables nav: - 'Home': 'index.md' diff --git a/web-docs/reference/flag-configuration.md b/web-docs/reference/flag-configuration.md index 79f46cd79..f189c397c 100644 --- a/web-docs/reference/flag-configuration.md +++ b/web-docs/reference/flag-configuration.md @@ -1,20 +1,4 @@ # Flag Configuration - -- [Flag Configuration](#flag-configuration) - - [Flags](#flags) - - [Flag configuration](#flag-configuration-1) - - [Flag properties](#flag-properties) - - [State](#state) - - [Variants](#variants) - - [Default Variant](#default-variant) - - [Targeting Rules](#targeting-rules) - - [Evaluation Context](#evaluation-context) - - [Conditions](#conditions) - - [Operations](#operations) - - [Custom Operations](#custom-operations) - - [Shared evaluators](#shared-evaluators) - - [Examples](#examples) - ## Flags `flags` is a **required** property. @@ -180,9 +164,9 @@ The evaluation context can be accessed in targeting rules using the `var` operat | Description | Example | | -------------------------------------------------------------- | --------------------------------------------- | -| Retrieve property from the evaluation context | `{ "var": "email" }` | -| Retrieve property from the evaluation context or use a default | `{ "var": ["email", "noreply@example.com"] }` | -| Retrieve a nested property from the evaluation context | `{ "var": "user.email" }` | +| Retrieve property from the evaluation context | `#!json { "var": "email" }` | +| Retrieve property from the evaluation context or use a default | `#!json { "var": ["email", "noreply@example.com"] }` | +| Retrieve a nested property from the evaluation context | `#!json { "var": "user.email" }` | > For more information, see the `var` section in the [JSON Logic documentation](https://jsonlogic.com/operations.html#var). @@ -192,10 +176,10 @@ Conditions can be used to control the logical flow and grouping of targeting rul | Conditional | Example | | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| If | Logic: `{"if" : [ true, "yes", "no" ]}`
Result: `"yes"`

Logic: `{"if" : [ false, "yes", "no" ]}`
Result: `"no"` | -| If else | Logic: `{"if" : [ false, "yes", false, "no", "maybe" ]}`
Result: `"maybe"`

Logic: `{"if" : [ false, "yes", false, "no", false, "maybe", "who knows" ]}`
Result: `"who knows"` | -| Or | Logic: `{"or" : [ true, false ]}`
Result: `true`

Logic: `{"or" : [ false, false ]}`
Result: `false` | -| And | Logic: `{"and" : [ true, false ]}`
Result: `false`

Logic: `{"and" : [ true, true ]}`
Result: `true` | +| If | Logic: `#!json {"if" : [ true, "yes", "no" ]}`
Result: `"yes"`

Logic: `#!json {"if" : [ false, "yes", "no" ]}`
Result: `"no"` | +| If else | Logic: `#!json {"if" : [ false, "yes", false, "no", "maybe" ]}`
Result: `"maybe"`

Logic: `#!json {"if" : [ false, "yes", false, "no", false, "maybe", "who knows" ]}`
Result: `"who knows"` | +| Or | Logic: `#!json {"or" : [ true, false ]}`
Result: `true`

Logic: `#!json {"or" : [ false, false ]}`
Result: `false` | +| And | Logic: `#!json {"and" : [ true, false ]}`
Result: `false`

Logic: `#!json {"and" : [ true, true ]}`
Result: `true` | #### Operations @@ -204,22 +188,22 @@ These are provided out-of-the-box by JsonLogic. | Operator | Description | Context type | Example | | ---------------------- | -------------------------------------------------------------------- | ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------- | -| Equals | Attribute equals the specified value, with type coercion. | any | Logic: `{ "==" : [1, 1] }`
Result: `true`

Logic: `{ "==" : [1, "1"] }`
Result: `true` | -| Strict equals | Attribute equals the specified value, with strict comparison. | any | Logic: `{ "===" : [1, 1] }`
Result: `true`

Logic: `{ "===" : [1, "1"] }`
Result: `false` | -| Not equals | Attribute doesn't equal the specified value, with type coercion. | any | Logic: `{ "!=" : [1, 2] }`
Result: `true`

Logic: `{ "!=" : [1, "1"] }`
Result: `false` | -| Strict not equal | Attribute doesn't equal the specified value, with strict comparison. | any | Logic: `{ "!==" : [1, 2] }`
Result: `true`

Logic: `{ "!==" : [1, "1"] }`
Result: `true` | -| Exists | Attribute is defined | any | Logic: `{ "!!": [ "mike" ] }`
Result: `true`

Logic: `{ "!!": [ "" ] }`
Result: `false` | -| Not exists | Attribute is not defined | any | Logic: `{"!": [ "mike" ] }`
Result: `false`

Logic: `{"!": [ "" ] }`
Result: `true` | -| Greater than | Attribute is greater than the specified value | number | Logic: `{ ">" : [2, 1] }`
Result: `true`

Logic: `{ ">" : [1, 2] }`
Result: `false` | -| Greater than or equals | Attribute is greater or equal to the specified value | number | Logic: `{ ">=" : [2, 1] }`
Result: `true`

Logic: `{ ">=" : [1, 1] }`
Result: `true` | -| Less than | Attribute is less than the specified value | number | Logic: `{ "<" : [1, 2] }`
Result: `true`

Logic: `{ "<" : [2, 1] }`
Result: `false` | -| Less than or equals | Attribute is less or equal to the specified value | number | Logic: `{ "<=" : [1, 1] }`
Result: `true`

Logic: `{ "<=" : [2, 1] }`
Result: `false` | -| Between | Attribute between the specified values | number | Logic: `{ "<" : [1, 5, 10]}`
Result: `true`

Logic: `{ "<" : [1, 11, 10] }`
Result: `false` | -| Between inclusive | Attribute between or equal to the specified values | number | Logic: `{"<=" : [1, 1, 10] }`
Result: `true`

Logic: `{"<=" : [1, 11, 10] }`
Result: `false` | -| Contains | Contains string | string | Logic: `{ "in": ["Spring", "Springfield"] }`
Result: `true`

Logic: `{ "in":["Illinois", "Springfield"] }`
Result: `false` | -| Not contains | Does not contain a string | string | Logic: `{ "!": { "in":["Spring", "Springfield"] } }`
Result: `false`

Logic: `{ "!": { "in":["Illinois", "Springfield"] } }`
Result: `true` | -| In | Attribute is in an array of strings | string | Logic: `{ "in" : [ "Mike", ["Bob", "Mike"]] }`
Result: `true`

Logic: `{ "in":["Todd", ["Bob", "Mike"]] }`
Result: `false` | -| Not it | Attribute is not in an array of strings | string | Logic: `{ "!": { "in" : [ "Mike", ["Bob", "Mike"]] } }`
Result: `false`

Logic: `{ "!": { "in":["Todd", ["Bob", "Mike"]] } }`
Result: `true` | +| Equals | Attribute equals the specified value, with type coercion. | any | Logic: `#!json { "==" : [1, 1] }`
Result: `true`

Logic: `#!json { "==" : [1, "1"] }`
Result: `true` | +| Strict equals | Attribute equals the specified value, with strict comparison. | any | Logic: `#!json { "===" : [1, 1] }`
Result: `true`

Logic: `#!json { "===" : [1, "1"] }`
Result: `false` | +| Not equals | Attribute doesn't equal the specified value, with type coercion. | any | Logic: `#!json { "!=" : [1, 2] }`
Result: `true`

Logic: `#!json { "!=" : [1, "1"] }`
Result: `false` | +| Strict not equal | Attribute doesn't equal the specified value, with strict comparison. | any | Logic: `#!json { "!==" : [1, 2] }`
Result: `true`

Logic: `#!json { "!==" : [1, "1"] }`
Result: `true` | +| Exists | Attribute is defined | any | Logic: `#!json { "!!": [ "mike" ] }`
Result: `true`

Logic: `#!json { "!!": [ "" ] }`
Result: `false` | +| Not exists | Attribute is not defined | any | Logic: `#!json {"!": [ "mike" ] }`
Result: `false`

Logic: `#!json {"!": [ "" ] }`
Result: `true` | +| Greater than | Attribute is greater than the specified value | number | Logic: `#!json { ">" : [2, 1] }`
Result: `true`

Logic: `#!json { ">" : [1, 2] }`
Result: `false` | +| Greater than or equals | Attribute is greater or equal to the specified value | number | Logic: `#!json { ">=" : [2, 1] }`
Result: `true`

Logic: `#!json { ">=" : [1, 1] }`
Result: `true` | +| Less than | Attribute is less than the specified value | number | Logic: `#!json { "<" : [1, 2] }`
Result: `true`

Logic: `#!json { "<" : [2, 1] }`
Result: `false` | +| Less than or equals | Attribute is less or equal to the specified value | number | Logic: `#!json { "<=" : [1, 1] }`
Result: `true`

Logic: `#!json { "<=" : [2, 1] }`
Result: `false` | +| Between | Attribute between the specified values | number | Logic: `#!json { "<" : [1, 5, 10]}`
Result: `true`

Logic: `#!json { "<" : [1, 11, 10] }`
Result: `false` | +| Between inclusive | Attribute between or equal to the specified values | number | Logic: `#!json {"<=" : [1, 1, 10] }`
Result: `true`

Logic: `#!json {"<=" : [1, 11, 10] }`
Result: `false` | +| Contains | Contains string | string | Logic: `#!json { "in": ["Spring", "Springfield"] }`
Result: `true`

Logic: `#!json { "in":["Illinois", "Springfield"] }`
Result: `false` | +| Not contains | Does not contain a string | string | Logic: `#!json { "!": { "in":["Spring", "Springfield"] } }`
Result: `false`

Logic: `#!json { "!": { "in":["Illinois", "Springfield"] } }`
Result: `true` | +| In | Attribute is in an array of strings | string | Logic: `#!json { "in" : [ "Mike", ["Bob", "Mike"]] }`
Result: `true`

Logic: `#!json { "in":["Todd", ["Bob", "Mike"]] }`
Result: `false` | +| Not it | Attribute is not in an array of strings | string | Logic: `#!json { "!": { "in" : [ "Mike", ["Bob", "Mike"]] } }`
Result: `false`

Logic: `#!json { "!": { "in":["Todd", ["Bob", "Mike"]] } }`
Result: `true` | #### Custom Operations @@ -228,10 +212,10 @@ They are purpose built extensions to JsonLogic in order to support common featur | Function | Description | Example | | ------------- | --------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `fractional` | Deterministic, pseudorandom fractional distribution | Logic: `{ "fractional" : [ { "var": "email" }, [ "red" , 50], [ "green" , 50 ] ] }`
Result: Pseudo randomly `red` or `green` based on the evaluation context property `email`.

Additional documentation can be found [here](./custom-operations/fractional.md) | -| `starts_with` | Attribute starts with the specified value | Logic: `{ "starts_with" : [ "192.168.0.1", "192.168"] }`
Result: `true`

Logic: `{ "starts_with" : [ "10.0.0.1", "192.168"] }`
Result: `false`
Additional documentation can be found [here](./custom-operations/string-comparision.md) | -| `ends_with` | Attribute ends with the specified value | Logic: `{ "ends_with" : [ "noreply@example.com", "@example.com"] }`
Result: `true`

Logic: `{ ends_with" : [ "noreply@example.com", "@test.com"] }`
Result: `false`
Additional documentation can be found [here](./custom-operations/string-comparision.md) | -| `sem_ver` | Attribute matches a semantic versioning condition | Logic: `{"sem_ver": ["1.1.2", ">=", "1.0.0"]}`
Result: `true`

Additional documentation can be found [here](./custom-operations/semver-comparison.md) | +| `fractional` | Deterministic, pseudorandom fractional distribution | Logic: `#!json { "fractional" : [ { "var": "email" }, [ "red" , 50], [ "green" , 50 ] ] }`
Result: Pseudo randomly `red` or `green` based on the evaluation context property `email`.

Additional documentation can be found [here](./custom-operations/fractional.md) | +| `starts_with` | Attribute starts with the specified value | Logic: `#!json { "starts_with" : [ "192.168.0.1", "192.168"] }`
Result: `true`

Logic: `#!json { "starts_with" : [ "10.0.0.1", "192.168"] }`
Result: `false`
Additional documentation can be found [here](./custom-operations/string-comparision.md) | +| `ends_with` | Attribute ends with the specified value | Logic: `#!json { "ends_with" : [ "noreply@example.com", "@example.com"] }`
Result: `true`

Logic: `#!json { ends_with" : [ "noreply@example.com", "@test.com"] }`
Result: `false`
Additional documentation can be found [here](./custom-operations/string-comparision.md) | +| `sem_ver` | Attribute matches a semantic versioning condition | Logic: `#!json {"sem_ver": ["1.1.2", ">=", "1.0.0"]}`
Result: `true`

Additional documentation can be found [here](./custom-operations/semver-comparison.md) | ## Shared evaluators