json_schema icon indicating copy to clipboard operation
json_schema copied to clipboard

Incorrect result of ValidationResults.toString()

Open EvgeniShmakov opened this issue 1 year ago • 0 comments

Type

Bug

Details

The result of ValidationResults.toString() is incorrect due to wrong order in conditional operators.

class ValidationResults {
  @override
  String toString() {
    return '${errors.isEmpty ? 'VALID' : 'INVALID'}${errors.isEmpty ? ', Errors: $errors' : ''}${warnings.isEmpty ? ', Warnings: $warnings' : ''}';
  }
}

Possible Solution

class ValidationResults {
  @override
  String toString() {
    return '${errors.isEmpty ? 'VALID' : 'INVALID'}${errors.isEmpty ? '' : ', Errors: $errors'}${warnings.isEmpty ? '' : ', Warnings: $warnings'}';
  }
}

EvgeniShmakov avatar Apr 22 '24 14:04 EvgeniShmakov