Wiki 9Minecraft Wiki 9Minecraft
Azusaconfig Wiki › Guides › Validate and Constrain Configuration Values

Validate and Constrain Configuration Values

Setting Value Ranges

Use AzusaConfig's constraint annotations to define acceptable ranges for numeric settings. Specify minimum and maximum values to prevent players from entering invalid numbers that could break gameplay.

Handling Invalid Entries

When a player edits the config file with an out-of-range value, AzusaConfig can either reject the change or clamp it to the nearest valid value. Configure this behavior based on your mod's needs.

Validating String Options

For string-based settings, define a whitelist of allowed values. This ensures players can only select from valid options, preventing typos or unsupported configurations.

Testing Edge Cases

Manually edit your config file with boundary values and invalid entries to verify validation works as intended. Check that your mod handles rejected values gracefully without crashing.

Proper validation prevents player confusion and protects your mod from misconfiguration.