validateMaxLines function

int validateMaxLines(
  1. int? maxLines, {
  2. int? defaultValue,
  3. bool? enableSecurity,
})

Validates max lines within configured bounds.

Implementation

int validateMaxLines(int? maxLines, {int? defaultValue, bool? enableSecurity}) {
  final shouldValidate = enableSecurity ?? TextSecurityConfig.enforceValidation;

  if (maxLines == null) return defaultValue ?? TextSecurityConfig.maxMaxLines;
  if (!shouldValidate) return maxLines;

  if (maxLines < 1) {
    if (TextSecurityConfig.enableSecurityLogging) {
      debugPrint('[SAC Text Security] Max lines $maxLines is invalid, using 1');
    }
    return 1;
  }

  if (maxLines > TextSecurityConfig.maxMaxLines) {
    if (TextSecurityConfig.enableSecurityLogging) {
      debugPrint(
        '[SAC Text Security] Max lines $maxLines above max ${TextSecurityConfig.maxMaxLines}',
      );
    }
    return TextSecurityConfig.maxMaxLines;
  }

  return maxLines;
}