1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-28 00:06:53 +01:00
unleash.unleash/website/docs/reference/feature-flag-naming-patterns.mdx

35 lines
2.4 KiB
Plaintext
Raw Normal View History

---
title: Feature Flag Naming Patterns
---
:::info Availability
Feature flag naming patterns is an **enterprise-only** feature released in Unleash v5.7.
:::
A feature flag naming pattern is [JavaScript regular expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp) that is used to validate the name of a feature flag before the flag can be created.
The pattern is defined in the project settings and is enforced when creating a new feature flag. The pattern is also enforced when creating a new feature flag via the API.
Patterns are implicitly anchored to the start and end of the string. This means that a pattern is matched against the entire new feature flag name, and not just any subset of it, as if the pattern was surrounded by `^` and `$`. In other words, the pattern `[a-z]+` will be interpreted as `^[a-z]+$` and will match "somefeature", but will not match "some.other.feature".
Feature flag naming patterns are defined on a per-project basis.
In addition to the pattern itself, you can also define an example and a description of the pattern. If defined, both the example and the description will be shown to the user when they are creating a new feature flag.
## Overview
The naming pattern consists of three parts:
<dl>
<dt><strong>Pattern</strong> (required)</dt>
<dd>The <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp">regular expression</a> that is used to validate the name of the feature flag. Must be a valid regular expression. Flags (such as case insensitivity) are not available.</dd>
<dt><strong>Example</strong> (optional)</dt>
<dd>An example of a name that is valid according to the provided pattern. Note: the example <strong>must</strong> be valid against the described pattern for it to be saved.</dd>
<dt><strong>Description</strong> (optional)</dt>
<dd>Any additional text that you would like to display to users to provide extra information. This can be anything that you think they would find useful and can be as long or short as you want.</dd>
</dl>
For instance, you might define a pattern that requires all feature flags to follow a specific pattern, such as `^(red|blue|green|yellow)\.[a-z-]+\.[0-9]+$`. You could then provide an example of a valid feature flag name (for instance "blue.water-gun.64") and a description of what the pattern should reflect: "`<team>.<feature>.<ticket>`".