validate_percentage_or_int
- gratools.validate_percentage_or_int(ctx, param, value)[source]
Click callback for validating that an option’s value is either an integer or a float representing a percentage (between 0.0 and 1.0 inclusive).
This function is intended to be used as a callback for a Click option.
- Parameters:
- Returns:
int | float –
- The validated value, converted to int if it’s a whole number,
or float if it’s a percentage (0.0-1.0).
- Raises:
click.BadParameter – If the value is not a valid integer or a float between 0.0 and 1.0.
- Return type: