Repository: vapor/vapor
File: Sources/Vapor/Validation/ValidatorResult.swift (Swift)

Code before:
extension ValidatorResults.Nested: ValidatorResult {
    public var isFailure: Bool {
        !self.results.filter { $0.isFailure }.isEmpty
    }
    
    public var successDescription: String? {
        self.results.filter { !$0.isFailure }
            .compactMap { $0.successDescription }
            .joined(separator: " and ")
    }
    
    public var failureDescription: String? {
        self.results.filter { $0.isFailure }
            .compactMap { $0.failureDescription }
            .joined(separator: " and ")
    }
}

extension ValidatorResults.NestedCollection: ValidatorResult {
    public var isFailure: Bool {
        !self.results.flatMap { $0.value }
            .filter { $0.isFailure }.isEmpty
    }
    
    public var successDescription: String? {
        self.results.flatMap { nested in
            nested.value.filter { !$0.isFailure }
                .compactMap { $0.successDescription }
                .map { "[\(nested.key)] \($0)" }
        }.joined(separator: " and ")
    }
    
    public var failureDescription: String? {
        self.results.flatMap { nested in
            nested.value.filter { $0.isFailure }
                .compactMap { $0.failureDescription }
                .map { "[\(nested.key)] \($0)" }
        }.joined(separator: " and ")
    }
}

extension ValidatorResults.Skipped: ValidatorResult {
    public var isFailure: Bool {
        false
    }
    
    public var successDescription: String? {
        nil
    }
    
    public var failureDescription: String? {

Review comment (suggestion):
With `[[ValidatorResult]]` you could do `self.results.enumerated()` to get the key.

Code after:
extension ValidatorResults.Nested: ValidatorResult {
    public var isFailure: Bool {
        !self.results.filter { $0.isFailure }.isEmpty
    }
    
    public var successDescription: String? {
        self.results.filter { !$0.isFailure }
            .compactMap { $0.successDescription }
            .joined(separator: " and ")
    }
    
    public var failureDescription: String? {
        self.results.filter { $0.isFailure }
            .compactMap { $0.failureDescription }
            .joined(separator: " and ")
    }
}

extension ValidatorResults.NestedCollection: ValidatorResult {
    public var isFailure: Bool {
        !self.results.flatMap { $0 }
            .filter { $0.isFailure }.isEmpty
    }
    
    public var successDescription: String? {
        self.results.enumerated().flatMap { nested in
            nested.element.filter { !$0.isFailure }
                .compactMap { $0.successDescription }
                .map { "Index \(nested.offset) \($0)" }
        }.joined(separator: " and ")
    }
    
    public var failureDescription: String? {
        self.results.enumerated().flatMap { nested in
            nested.element.filter { $0.isFailure }
                .compactMap { $0.failureDescription }
                .map { "Index \(nested.offset) \($0)" }
        }.joined(separator: " and ")
    }
}

extension ValidatorResults.Skipped: ValidatorResult {
    public var isFailure: Bool {
        false
    }
    
    public var successDescription: String? {
        nil
    }
    
    public var failureDescription: String? {