New Comparators in Config V2
Config V2 introduces New Comparators that make it much easier to create precise Targeting Rules by facilitating seamless comparison of texts, arrays, and dates.
Overview
The latest release showcases a variety of new comparators, each designed to offer specific functionalities for handling texts, arrays, and dates.
In this post, we'll illustrate these comparators with various examples.
New Text Comparators
In Config V2, we're introducing new text comparators, expanding your toolkit with options like EQUALS
, NOT EQUALS
, STARTS WITH ANY OF
, NOT STARTS WITH ANY OF
, ENDS WITH ANY OF
, and NOT ENDS WITH ANY OF
. Let's see them one by one.
EQUALS
Check if a given string exactly matches the specified value. For example:
"userType" EQUALS "admin"
Ensures only users with the type 'admin' are targeted.
NOT EQUALS
Determines if a string does not match the provided value. For example:
"Country" NOT EQUALS "Canada"
Targets all users outside Canada.
STARTS WITH ANY OF
Tests if a string starts with any of the specified substrings. For example:
"Email" STARTS WITH ANY OF ["info@", "support@"]
Would target emails starting with 'info@' or 'support@'.
NOT STARTS WITH ANY OF
Ensures a string does not start with any of the specified prefixes. For example:
"username" NOT STARTS WITH ANY OF ["temp", "guest"]
Excludes users with 'temp' or 'guest'.
ENDS WITH ANY OF
Check if a string ends with any of the given substrings. For example:
"file" ENDS WITH ANY OF [".pdf", ".docx"]
Targets only files ending in .pdf or .docx.
NOT ENDS WITH ANY OF
Confirms a string does not end with any of the listed suffixes. For example:
"image" NOT ENDS WITH ANY OF [".png", ".jpg"]
Excludes images ending in .png or .jpg.
Date & Time Comparators
ConfigCat now includes Date and Time comparators, namely BEFORE
and AFTER
, making feature flag management simpler than ever. These comparators are perfect for managing time-specific campaigns like summer sales, Black Friday events, Christmas promotions, and more. They help you easily control when your promotions start and end, making it simple to run successful marketing campaigns.
BEFORE
Compares if a date is earlier than the specified date. For example:
"expiryDate" BEFORE "2022-12-31"
Targets all items that expire before January 1, 2023.
AFTER
Determines if a date is later than the provided date. For example:
"startDate" AFTER "2023-01-01"
Would target items starting from January 2, 2023.
Array Comparators
When it comes to managing arrays of strings, Config V2 offers powerful tools known as Array Comparators. These comparators are designed to handle arrays efficiently, simplifying complex comparisons.
ARRAY CONTAINS ANY OF
Verifies if any element of the array matches any of the specified values. For example:
"tags" ARRAY CONTAINS ANY OF ["urgent", "high-priority"]
Targets items tagged as 'urgent' or 'high-priority'.
ARRAY NOT CONTAINS ANY OF
Check if the array does not contain any of the specified elements. For example:
"features" ARRAY NOT CONTAINS ANY OF ["beta"]
Targets all feature sets that do not include 'beta'.
Conclusion
What sets Config V2 apart is the ability to mix and match these comparators, empowering you to precisely tailor your Targeting Rules according to your desired user base. By implementing these comparators for texts, dates, and arrays, you ensure that your features reach the right users at the right time, enhancing both functionality and user satisfaction.
For more insights and updates on our latest tools, follow ConfigCat on X, Facebook, LinkedIn, and GitHub.