Skip to content

Policies

Policies are the rule sets that determine if a feature flag is active or not for a given context.

Policy Structure

Policies are defined as a set of rules against a specific piece of data from the Context

There are four types of rules that can be defined within a policy:

Expressions

Expressions are for matching values within the Context.

Operators

Operators are used to compare the subject against a value.

Context Value TypeOperatorPolicy Value TypeDescription
scalar=scalarContext and Policy values are identical
scalar!=scalarContext and Policy values are not identical
scalar<, <=, >, >=scalarContext value is <, <=, >, >= than the Policy value
scalarcontains exactly, contains anyscalarContext value contains the Policy value (as strings)
scalardoes not contains exactly, does not contains anyscalarContext value does not contain the Policy value (as strings)
scalarregex match exactly, regex match anyscalarContext value matches the Policy value as regex
scalardoes not regex match exactly, does not regex match anyscalarContext value does not match the Policy value as regex
scalaris one ofscalarUnsupported
scalaris not one ofscalarUnsupported
scalar=, is one ofarrayContext value exists within the Policy array
scalar!=, is not one ofarrayContext value does not exist within the Policy array
scalarcontains exactlyarrayContext value contains all of the Policy values
scalarcontains anyarrayContext value contains one of the Policy values
scalardoes not contains exactlyarrayContext value is not contained in all of the Policy values
scalardoes not contains anyarrayContext value is not contained in one of the Policy values
scalarregex match exactlyarrayContext value matches all of the Policy values as regex
scalarregex match anyarrayContext matches one of the Policy array values as regex
scalardoes not regex match exactlyarrayContext value does not match all of the Policy values as regex
scalardoes not regex match anyarrayThe Context value does not match any of the Policy values as regex
scalaris not one ofarrayContext value does not exist within the Policy array
scalar<, <=, >, >=arrayUnsupported
array=scalarOne of the Context values is identical to the Policy value
array!=scalarNone of the Context values are identical to the Policy value
arraycontains exactlyscalarAll of the Context values within the Policy value (as strings)
arraydoes not contain exactlyscalarAll of the Context values do not exist within the Policy value (as strings)
arraycontains anyscalarOne of the Context values exists within the Policy value (as strings)
arraydoes not contains anyscalarOne of the Context values does not exist within the Policy value (as strings)
arrayregex match exactlyscalarAll of the Context Values match the Policy value as regex
arraydoes not regex match exactlyscalarAll of the Context values do not match the Policy value as regex
arrayregex match anyscalarOne of the Context values matches the Policy value as regex
arraydoes not regex match anyscalarOne of the Context values does not match the Policy value as regex
arrayis one ofscalarUnsupported
arrayis not one ofscalarUnsupported
array<, <=, >, >=scalarAll Context values are <, <=, >, >= to the Policy value
array=arrayContext and Policy values are identical (ordering ignored)
array!=arrayContext and Policy values are not identical (ordering ignored)
arraycontains exactlyarrayAll Context values exist within the Policy array
arraydoes not contains exactlyarrayAll of the Context values do not exist within the Policy array
arraycontains anyarrayOne of the Context values exists within the Policy array
arraydoes not contains anyarrayNone of the Context values exist within the Policy array
arrayregex match exactlyarrayAll of the Context values match all of the Policy values as regex
arraydoes not regex match exactlyarrayAll of the Context values do not match all of the Policy values as regex
arrayregex match anyarrayOne of the Context values matches one of the Policy values as regex
arraydoes not regex match anyarrayAll of the Context values do not match any of the Policy values as regex
arrayis one ofarrayAll of the Context values exist within the Policy array
arrayis not one ofarrayAll of the Context values do not exist within the Policy array
array<, <=, >, >=arrayUnsupported

Policies

You can nest policies within policies. This allows for more complex policies to be defined using composition.

NOTE

Beacon will detect recursive policies and disallow them. This is to prevent infinite loops in policy evaluation.

Date/Time

Date/Time rules are for time-based feature flag activation. They allow you to enable or disable features based on specific dates and times.

The context value is a date/time string that will be parsed and compared against the current time. The supported operators are:

Operators

  • less than or equal (<=): Feature is active if current time is before or equal to the specified date/time
  • greater than or equal (>=): Feature is active if current time is after or equal to the specified date/time (default behavior)

Examples

Activate a feature until a specific date:

  • Type: DateTime
  • Operator: <=
  • Context Value: 2025-12-31 23:59:59

Activate a feature after a specific date:

  • Type: DateTime
  • Operator: >=
  • Context Value: 2025-01-01 00:00:00

Operators

Operators are used to create boolean expressions between Expressions, Policies, and DateTime rules.

Made with 🦁💖🏳️‍🌈 by Davey Shafik.