getFormattedErrors method

String getFormattedErrors()

Gets a formatted string representation of all validation issues.

Implementation

String getFormattedErrors() {
  final buffer = StringBuffer();

  if (errors.isNotEmpty) {
    buffer.writeln('Errors:');
    for (final error in errors) {
      buffer.writeln('  - ${error.message}');
    }
  }

  if (warnings.isNotEmpty) {
    if (buffer.isNotEmpty) buffer.writeln();
    buffer.writeln('Warnings:');
    for (final warning in warnings) {
      buffer.writeln('  - ${warning.message}');
    }
  }

  if (suggestions.isNotEmpty) {
    if (buffer.isNotEmpty) buffer.writeln();
    buffer.writeln('Suggestions:');
    for (final suggestion in suggestions) {
      buffer.writeln('  - $suggestion');
    }
  }

  return buffer.toString().trim();
}