Unleash brings powerful Constraints feature to OSS users
Tags: opensource, github, devops, tooling
Published: 2022-10-04 13:41:36

**[Unleash](https://www.getunleash.io/?utm_source=dev.to&utm_medium=referral+&utm_campaign=constraints_04102022) is the largest open-source feature flagging solution on Github, that gives developers greater control over how to deploy new features. There are 12 official client and server SDKs and 10+ community SDKs available for greater flexibility and control over data and feature management deployment.**

One of Unleash’s most requested Enterprise features is now available to all users.

You spoke, we listened: Available now, all open-source users of Unleash who upgrade to version 4.16 will get access to [strategy constraints](https://docs.getunleash.io/advanced/strategy_constraints) and [custom context fields](https://docs.getunleash.io/user_guide/unleash_context#custom-context-fields).

**Add strategy constraints to your Unleash today**

[![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qc7pvawg0avu71ikiiq0.png)](https://github.com/Unleash/unleash) [![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x5pxyf1utllp1x3lps14.png)	](https://docs.getunleash.io/deploy/migration_guide)

## **What are Strategy Constraints?**

Strategy constraints give you granular control over who gets to see a specific feature by adding preconditions to one of your activation strategies. You can add preconditions for any Unleash context field. As of version 4.16, Unleash supports [15 different constraint operators](https://docs.getunleash.io/advanced/strategy_constraints), fine-tuned for a number of use cases.

{% embed https://youtu.be/kqtqMFhLRBE %}

Here’s an example: A gradual rollout strategy could target 50% of a user base. But what if you want to only target users with a company email? For that, you’ll need strategy constraints. 

Quickly schedule feature releases and feature availability windows. Target feature rollout to users based on variables like region or email address domain. Generate user demand with time-limited feature releases. There are a ton of ways to use strategy constraints, and this is only scratching the surface. 

Any strategy on any feature can have as many strategy constraints as you want. Note that when a strategy is evaluated, all strategy constraints must be met for the strategy to pass.

You’ll find that, in most cases, strategy constraints replace the need for [custom activation strategies](https://docs.getunleash.io/advanced/custom_activation_strategy). This means that you no longer need to define custom strategies, then implement them across your SDKs. 

## **How do I use strategy constraints?**

Note: Before creating strategy constraints, you’ll need to set up a [feature toggle](https://docs.getunleash.io/user_guide/create_feature_toggle) in Unleash, then give it an [activation strategy](https://docs.getunleash.io/user_guide/activation_strategy). 

**Open the constraints menu**
Find and select the **edit strategy** button on the strategy you are working with.

!["edit strategy" button on the strategy screen](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e2f8d8oiy7uez78xde9k.jpg)


Click the "add constraint" button to open the constraints menu.

!["add constraint" button](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0g8et8yl5swi5gggkvdy.jpg)



**Add and configure the constraint**
1. From the **"Context Field"** dropdown,  select the context field you would like to constrain the strategy on. Choose a constraint operator.
2. Define the values to use for this constraint. The operator you select determines whether you can define one or multiple values and what format they can have.
3. Save the constraint, then save the strategy.

![Add and configure the constraint](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i7j6iml1b7jmlp55mjg3.jpg)



If you want to update an existing constraint, find the constraint in the **edit strategy** screen and use the constraint’s **edit** button.

Because strategy constraints use Unleash context fields, make sure you pass the relevant context to your [client SDK](https://docs.getunleash.io/sdks). Read more in the SDK section of our the SDK section of the [strategy constraints documentation](https://docs.getunleash.io/advanced/strategy_constraints#sdks). 

## **Strategy constraints are available today to all version 4.16 open source users**

While strategy constraints are now free to all users, you won’t have access to the feature unless you upgrade to version 4.16. For users with versions 4.0 and above, you can grab the latest version from the Docker hub. Users of earlier versions should reference our [migration guide](https://docs.getunleash.io/deploy/migration_guide) before upgrading.  

Feel free to play around first! Try out our [demo instance](https://app.unleash-hosted.com/demo) to get a quick taste of what strategy constraints can do. 

In the mood to dig around? Visit [Unleash on GitHub](https://github.com/Unleash/unleash) to check out the strategy constraints source code.

## **Want to try out strategy constraints?**


[![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qc7pvawg0avu71ikiiq0.png)](https://github.com/Unleash/unleash)