@@ -80,7 +80,7 @@ extension KeyedDecodingContainer where K == AnyCodingKey {
8080 return container. tryDecodeWithNormalKey ( type: type, key: lastKey)
8181 }
8282
83- public func match< T: Decodable & Equatable > ( keyPathValues: [ ( String , Any , T . Type ) ] ) -> Bool {
83+ public func match< T: Decodable & Comparable > ( keyPathValues: [ ( String , Any , T . Type ) ] ) -> Bool {
8484 for (path, value, _) in keyPathValues {
8585 var expectedValue : ( any Equatable ) ?
8686 var expectedRange : ( any RangeExpression < T > ) ?
@@ -101,7 +101,15 @@ extension KeyedDecodingContainer where K == AnyCodingKey {
101101 if let foundValue = try ? decode ( type: T . self, keys: [ path] ) {
102102 if let expectedValue = expectedValue as? T {
103103 return foundValue == expectedValue
104- } else if let expectedRange {
104+ } else if let expectedRange = expectedRange as? Range < T > {
105+ return expectedRange. contains ( foundValue)
106+ } else if let expectedRange = expectedRange as? ClosedRange < T > {
107+ return expectedRange. contains ( foundValue)
108+ } else if let expectedRange = expectedRange as? PartialRangeFrom < T > {
109+ return expectedRange. contains ( foundValue)
110+ } else if let expectedRange = expectedRange as? PartialRangeThrough < T > {
111+ return expectedRange. contains ( foundValue)
112+ } else if let expectedRange = expectedRange as? PartialRangeUpTo < T > {
105113 return expectedRange. contains ( foundValue)
106114 } else {
107115 return true
0 commit comments