validateOTPFontSize function

double validateOTPFontSize(
  1. double? fontSize, {
  2. required double defaultValue,
  3. bool? enableSecurity,
})

Validates font size within configured bounds.

Implementation

double validateOTPFontSize(
  double? fontSize, {
  required double defaultValue,
  bool? enableSecurity,
}) {
  final shouldValidate = enableSecurity ?? OTPSecurityConfig.enforceValidation;

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

  if (fontSize > OTPSecurityConfig.maxFontSize) {
    if (OTPSecurityConfig.enableSecurityLogging) {
      debugPrint(
        '[SAC OTP Security] Font size $fontSize above max ${OTPSecurityConfig.maxFontSize}',
      );
    }
    return OTPSecurityConfig.maxFontSize;
  }

  if (fontSize < OTPSecurityConfig.minFontSize) {
    if (OTPSecurityConfig.enableSecurityLogging) {
      debugPrint(
        '[SAC OTP Security] Font size $fontSize below min ${OTPSecurityConfig.minFontSize}',
      );
    }
    return OTPSecurityConfig.minFontSize;
  }

  return fontSize;
}