Skip to content

feature: string pattern anonymizer, build complex strings by fetching values from other anonymizers#224

Merged
pounard merged 1 commit intomainfrom
datalist-2bis-string-pattern
Jul 22, 2025
Merged

feature: string pattern anonymizer, build complex strings by fetching values from other anonymizers#224
pounard merged 1 commit intomainfrom
datalist-2bis-string-pattern

Conversation

@pounard
Copy link
Copy Markdown
Member

@pounard pounard commented Jul 22, 2025

See documentation for more information.

TL;DR:

anonymization:
    default:
        customer:
            biography:
                anonymizer: pattern
                options: {value: '{firstname} {lastname} lives in {address:locality} in {address:country}, he has [2,7] cats.'}

String range

By adding [MIN,MAX] anywhere in your text, it will be replaced by a random integer
in the given range. For example "I want [7-111] apples".

You can use negative integers such as [-10,10] or even a fully negative integer
range [-127,-34].

Single value from another anonymizer

By adding {ANONYMIZER} anywhere in your text, it will be replaced by a random value
given by the anonymizer. For example "My email address is {email}, what's your ?".

Column value from another anonymizer

By adding {ANONYMIZER:COLUMN} anywhere in your text, it will be replaced by a random
value for the named column given by the anonymizer. For example, "The country I live into is {address:country}.".

If you use more than one column of the same anonymizer in the same text value, the same
generated row from the target anonymizer will be used. For example, this text will give
a consistent result: "The country I live in {address:locality} in {address:country}.".

@pounard pounard force-pushed the datalist-2bis-string-pattern branch 4 times, most recently from ffbc061 to f8bd145 Compare July 22, 2025 09:22
Copy link
Copy Markdown
Member

@SimonMellerin SimonMellerin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems really good !

Maybe an alternative could be to accept this kind of conf

anonymization:
    default:
        customer:
            biography:
                anonymizer: pattern
                options: 
                     value: '{1} {2} has email address {3}.'
                     1: firstname
                     2: lastname
                     3: 
                         anonymizer: email
                         options: {domain: 'custom-domain.com'}

This can be an addition for advanced cases. what do you think ?

But this is may be far too complex for a first version.

Comment thread docs/content/anonymization/core-anonymizers/pattern.md Outdated
Comment thread docs/content/anonymization/core-anonymizers/pattern.md Outdated
Comment thread docs/content/anonymization/core-anonymizers/pattern.md Outdated
@pounard
Copy link
Copy Markdown
Member Author

pounard commented Jul 22, 2025

Maybe an alternative could be to accept this kind of conf

It seems vastly different from what I have done, but it's definitely an interesting idea. How about opening an issue to add this dialect variant as well ?

Comment thread docs/content/anonymization/core-anonymizers/pattern.md
@pounard pounard force-pushed the datalist-2bis-string-pattern branch from 79537e4 to fa4a3fc Compare July 22, 2025 13:29
Comment thread docs/content/anonymization/core-anonymizers/pattern.md Outdated
Comment thread docs/content/anonymization/core-anonymizers/pattern.md Outdated
@pounard pounard force-pushed the datalist-2bis-string-pattern branch from fa4a3fc to 626a83a Compare July 22, 2025 14:08
@pounard pounard merged commit ea798c7 into main Jul 22, 2025
11 checks passed
@pounard pounard deleted the datalist-2bis-string-pattern branch July 22, 2025 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants