Decode nil for single or keyed values if value is 'NA' or 'N/A'
This commit is contained in:
parent
f5940d49e9
commit
60eca9a4cc
|
@ -18,7 +18,8 @@ final class _CSVKeyedDecoder<K>: KeyedDecodingContainerProtocol where K: CodingK
|
||||||
}
|
}
|
||||||
|
|
||||||
func decodeNil(forKey key: K) throws -> Bool {
|
func decodeNil(forKey key: K) throws -> Bool {
|
||||||
return row[key.stringValue] == nil
|
let cell = row[key.stringValue]
|
||||||
|
return cell == nil || cell == Data([.N, .forwardSlash, .A]) || cell == Data([.N, .A])
|
||||||
}
|
}
|
||||||
|
|
||||||
func decode(_ type: Bool.Type, forKey key: K) throws -> Bool {
|
func decode(_ type: Bool.Type, forKey key: K) throws -> Bool {
|
||||||
|
|
|
@ -11,7 +11,9 @@ final class _CSVSingleValueDecoder: SingleValueDecodingContainer {
|
||||||
self.value = value
|
self.value = value
|
||||||
}
|
}
|
||||||
|
|
||||||
func decodeNil() -> Bool { return self.value == nil }
|
func decodeNil() -> Bool {
|
||||||
|
return value == nil || value == Data([.N, .forwardSlash, .A]) || value == Data([.N, .A])
|
||||||
|
}
|
||||||
|
|
||||||
func decode(_ type: Bool.Type) throws -> Bool {
|
func decode(_ type: Bool.Type) throws -> Bool {
|
||||||
guard let cell = self.value else { throw DecodingError.nilValue(type: type, at: self.codingPath) }
|
guard let cell = self.value else { throw DecodingError.nilValue(type: type, at: self.codingPath) }
|
||||||
|
|
Loading…
Reference in New Issue