Validate string and number flags with schemas and scoped hooks
GrowthBook extends schema validation to string and number flags and lets you attach Custom Hooks to a single feature. You can limit a flag to the values your code expects and give one flag its own checks, alongside broader organization and project rules.
Set boundaries for flag values
GrowthBook could already validate the shape of JSON flag values. Schema validation now covers string and number flags too, and is available with GrowthBook Enterprise. With validation enabled, you can:
- Restrict a string flag to approved values, such as classic, compact, or express.
- Set minimum and maximum values for a number flag, such as 10 to 100 results per page.
This is useful when several people edit a flag and only a few values are safe to serve. When someone tries to save a value that doesn't match the schema, GrowthBook shows an inline error with the reason it failed. Boolean flags can't have a schema.
Apply checks to one flag
Custom Hooks previously applied to every feature in an organization or project. On self-hosted GrowthBook Enterprise, you can now attach a hook to a single flag for rules that a schema can't express. For example, require a description before that flag is enabled in production.
The flag's Validation tab also lists the organization and project hooks that apply to it. Keep hooks fast and free of side effects, because a hook can run more than once during a save.
Getting started
- Open a string or number flag, go to its Validation tab, and click Enable under Schema Validation. Define the allowed values or numeric bounds, then try a value against them.
- To add a hook for one flag, you need edit access to that flag. Create the hook from the flag's Validation tab, and use the built-in test interface to run it before saving.
- Follow the Custom Hooks guide for hook types, scopes, and examples.