validateSize function

double validateSize(
  1. double? value, {
  2. required double defaultValue,
  3. double? min,
  4. double? max,
  5. bool? enableSecurity,
})

Implementation

double validateSize(
  double? value, {
  required double defaultValue,
  double? min,
  double? max,
  bool? enableSecurity,
}) {
  if (value == null) return defaultValue;
  final shouldValidate =
      enableSecurity ?? ButtonSecurityConfig.enforceValidation;
  if (!shouldValidate) return value;

  final effectiveMin = min ?? ButtonSecurityConfig.minButtonSize;
  final effectiveMax = max ?? ButtonSecurityConfig.maxButtonSize;

  if (value < effectiveMin) {
    _logSecurity('Size $value below minimum $effectiveMin, using minimum');
    return effectiveMin;
  }

  if (value > effectiveMax) {
    _logSecurity('Size $value above maximum $effectiveMax, using maximum');
    return effectiveMax;
  }

  return value;
}