validateDecorationThickness function

double validateDecorationThickness(
  1. double? thickness, {
  2. double defaultValue = 1.0,
  3. bool? enableSecurity,
})

Validates decoration thickness within configured bounds.

Implementation

double validateDecorationThickness(
  double? thickness, {
  double defaultValue = 1.0,
  bool? enableSecurity,
}) {
  final shouldValidate = enableSecurity ?? TextSecurityConfig.enforceValidation;

  if (thickness == null) return defaultValue;
  if (!shouldValidate) return thickness;

  if (thickness < 0) {
    if (TextSecurityConfig.enableSecurityLogging) {
      debugPrint(
        '[SAC Text Security] Decoration thickness $thickness is negative, using 0',
      );
    }
    return 0;
  }

  if (thickness > TextSecurityConfig.maxDecorationThickness) {
    if (TextSecurityConfig.enableSecurityLogging) {
      debugPrint(
        '[SAC Text Security] Decoration thickness $thickness above max ${TextSecurityConfig.maxDecorationThickness}',
      );
    }
    return TextSecurityConfig.maxDecorationThickness;
  }

  return thickness;
}