validateMaxLines function
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;
}