// EditOutputValidator.swift // OSGKeyboard · Shared import Foundation public enum EditOutputValidationError: Error, Equatable, Sendable { case empty case unchanged case protocolLeak case excessiveExpansion } public enum EditOutputValidator { public static func validate( sourceText: String, output: String ) -> Result { let source = normalized(sourceText) let result = output.trimmingCharacters(in: .whitespacesAndNewlines) guard !result.isEmpty else { return .failure(.empty) } guard normalized(result) != source else { return .failure(.unchanged) } let lowered = result.lowercased() let leaks = [ " String { text .trimmingCharacters(in: .whitespacesAndNewlines) .replacingOccurrences( of: "\\s+", with: " ", options: .regularExpression ) } }