From 2b9049aeaf4a8f5af9b1dc7ed1262941790f2f2b Mon Sep 17 00:00:00 2001 From: Josue Date: Tue, 16 Aug 2022 11:29:51 -0600 Subject: [PATCH] feat: docs for new reveal filter --- source/includes/expressions/_filters.md | 35 +++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/source/includes/expressions/_filters.md b/source/includes/expressions/_filters.md index 32d3375a..25ab1d97 100644 --- a/source/includes/expressions/_filters.md +++ b/source/includes/expressions/_filters.md @@ -199,6 +199,41 @@ Given a token with the data: | {{ data | last4 }} | "1667" | | {{ data | slice: 12, 2 | last4 }} | "67" | +## reveal + +Returns a masked version of the string revealing characters at the start and end whilst preserving others. If the string's +length is less than or equal to `reveal_first` + `reveal_last`, or the resulting masked string equals the original unmasked value, +the whole value is masked. + +### Parameters + +| Position | Name | Type | Required | Default Value | Description | +|----------|----------------|----------|----------|---------------|-------------------------------------------------| +| 0 | reveal_first | *int* | false | `0` | The number of characters to reveal at the start | +| 1 | reveal_last | *int* | false | `0` | The number of characters to reveal at the end | +| 2 | mask_char | *char* | false | `X` | A masking character | +| 3 | preserve_chars | *string* | false | `` | The characters to preserve | + +### Examples + +Given a token with the data: + +
+```json +{ + "id": "d35412f4-9d3b-45d8-b051-fe4b7d4e14c5", + "type": "token", + "data": "3622-7206-2716-5567" +} +``` + +| Expression | Result | +|-------------------------------------------------------|-----------------------| +| {{ data | reveal: 6 }} | "3622-7XXXXXXXXXXXXX" | +| {{ data | reveal: 7, 5 }} | "3622-72XXXXXXX-5567" | +| {{ data | reveal: 7, 5, '#' }} | "3622-72#######-5567" | +| {{ data | reveal: 7, 4, '#', "-" }} | "3622-72##-####-5567" | +| {{ data | reveal: 10, 9 }} | "XXXXXXXXXXXXXXXXXXX" | ## pad_left