Skip to content

Commit f8d50f7

Browse files
committed
Remove CharacterSet
1 parent 2aff4d1 commit f8d50f7

30 files changed

Lines changed: 186 additions & 186 deletions

IG/IG.xcodeproj/project.pbxproj

Lines changed: 40 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
8D0906A3236B4537005E7501 /* Date.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D0906A1236B4522005E7501 /* Date.swift */; };
1212
8D286D272344C8D000D582AE /* StreamerMarket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DC4CA592149A6CE00344CBF /* StreamerMarket.swift */; };
1313
8D286D282344CA8100D582AE /* StreamerMarketTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DC4CA8D2149A6CE00344CBF /* StreamerMarketTests.swift */; };
14+
8D2CC9E12477D45600B56599 /* Decimals in Frameworks */ = {isa = PBXBuildFile; productRef = 8D2CC9E02477D45600B56599 /* Decimals */; };
1415
8D2EA92B233B4E030004A4C2 /* API.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DC4CA7C2149A6CE00344CBF /* API.swift */; };
1516
8D2EA92C233B4E070004A4C2 /* APIError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DC4CA632149A6CE00344CBF /* APIError.swift */; };
1617
8D2EA92D233B545E0004A4C2 /* APIUser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D0A232B22EB9600001853E7 /* APIUser.swift */; };
@@ -111,7 +112,6 @@
111112
8D376DA3234C6300007D4A48 /* DBMigration+v1.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DE8A1A52349E33200031B1E /* DBMigration+v1.swift */; };
112113
8D376DA4234C6300007D4A48 /* DBApplication.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DA8F88F2317BF7200F1A2C0 /* DBApplication.swift */; };
113114
8D376DA5234C634B007D4A48 /* Lightstreamer_macOS_Client.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8DC1A4A4234B5C0200AD75C5 /* Lightstreamer_macOS_Client.framework */; };
114-
8D376DA6234C6376007D4A48 /* PlaygroundTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DF75CDB2322A85100130229 /* PlaygroundTests.swift */; };
115115
8D376DA7234C6379007D4A48 /* Test.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DD468D322F1C70100134B67 /* Test.swift */; };
116116
8D376DA8234C637B007D4A48 /* TestFabric.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DAEF08122F9994F005AB34C /* TestFabric.swift */; };
117117
8D376DA9234C6387007D4A48 /* TestAccount.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D4B971422F1C995002B267F /* TestAccount.swift */; };
@@ -191,7 +191,6 @@
191191
8D80CFD52341FDC300E63411 /* TestAccountDecodable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D80CFD42341FDC300E63411 /* TestAccountDecodable.swift */; };
192192
8D80CFD623421B2D00E63411 /* APISessionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DC4CAA42149A6CE00344CBF /* APISessionTests.swift */; };
193193
8D8472D3234B6917007432A8 /* Lightstreamer_iOS_Client.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8DC1A49F234B5B5700AD75C5 /* Lightstreamer_iOS_Client.framework */; platformFilter = ios; };
194-
8D84AB1C233A029600DFAFFF /* PlaygroundTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DF75CDB2322A85100130229 /* PlaygroundTests.swift */; };
195194
8D88F5F9246C79D900743B2B /* UTC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D88F5F8246C79D900743B2B /* UTC.swift */; };
196195
8D88F5FA246C79D900743B2B /* UTC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D88F5F8246C79D900743B2B /* UTC.swift */; };
197196
8D89C78B2343120C00FD0F3D /* APISentimentTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DF93B9922E75C11001B9412 /* APISentimentTests.swift */; };
@@ -226,6 +225,8 @@
226225
8DC7FBFF23E2F650002D7F5E /* ConbiniForTesting in Frameworks */ = {isa = PBXBuildFile; platformFilter = ios; productRef = 8DC7FBFE23E2F650002D7F5E /* ConbiniForTesting */; };
227226
8DCD2CE42366C4D50099259B /* APIPriceBatchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DCD2CE32366C4BF0099259B /* APIPriceBatchTests.swift */; };
228227
8DCD2CE52366C4DC0099259B /* APIPriceBatchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DCD2CE32366C4BF0099259B /* APIPriceBatchTests.swift */; };
228+
8DDB43AB2479704800A65CA5 /* CharacterSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DDB43AA2479704800A65CA5 /* CharacterSet.swift */; };
229+
8DDB43AC2479704800A65CA5 /* CharacterSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DDB43AA2479704800A65CA5 /* CharacterSet.swift */; };
229230
8DDBE9FA23506F1E001773D2 /* DBPriceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DDBE9F823506E7A001773D2 /* DBPriceTests.swift */; };
230231
8DDBE9FB23506F22001773D2 /* DBPriceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DDBE9F823506E7A001773D2 /* DBPriceTests.swift */; };
231232
8DDBE9FC2350820A001773D2 /* Services.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DC4CA432149A6CE00344CBF /* Services.swift */; };
@@ -373,7 +374,6 @@
373374
8DB266B9234B419E00F168CE /* StreamerLowlevelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StreamerLowlevelTests.swift; sourceTree = "<group>"; };
374375
8DB90A7E231E729F004204B8 /* DBMarketTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DBMarketTests.swift; sourceTree = "<group>"; };
375376
8DB90A80231E79BE004204B8 /* DBInternals.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DBInternals.swift; sourceTree = "<group>"; };
376-
8DC185592403D4BE00D2AD54 /* General.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; name = General.playground; path = "../../../../../../../../../Library/Autosave Information/General.playground"; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
377377
8DC1A49F234B5B5700AD75C5 /* Lightstreamer_iOS_Client.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Lightstreamer_iOS_Client.framework; path = Dependencies/Lightstreamer/Lightstreamer_iOS_Client.framework; sourceTree = "<group>"; };
378378
8DC1A4A4234B5C0200AD75C5 /* Lightstreamer_macOS_Client.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Lightstreamer_macOS_Client.framework; path = Dependencies/Lightstreamer/Lightstreamer_macOS_Client.framework; sourceTree = "<group>"; };
379379
8DC20A6F231AF3B000760FA4 /* DBNode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DBNode.swift; sourceTree = "<group>"; };
@@ -444,6 +444,7 @@
444444
8DC4CBFE2149AB1200344CBF /* environment */ = {isa = PBXFileReference; lastKnownFileType = folder; path = environment; sourceTree = "<group>"; };
445445
8DCD2CE32366C4BF0099259B /* APIPriceBatchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APIPriceBatchTests.swift; sourceTree = "<group>"; };
446446
8DD468D322F1C70100134B67 /* Test.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Test.swift; sourceTree = "<group>"; };
447+
8DDB43AA2479704800A65CA5 /* CharacterSet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CharacterSet.swift; sourceTree = "<group>"; };
447448
8DDBE9F823506E7A001773D2 /* DBPriceTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DBPriceTests.swift; sourceTree = "<group>"; };
448449
8DDBE9FE2350825F001773D2 /* ServicesError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServicesError.swift; sourceTree = "<group>"; };
449450
8DE2C3DD22FC72E400BB6261 /* DealLimit.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DealLimit.swift; sourceTree = "<group>"; };
@@ -454,7 +455,6 @@
454455
8DE50471245AD09C001BD304 /* UnfairLock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnfairLock.swift; sourceTree = "<group>"; };
455456
8DE8A1A52349E33200031B1E /* DBMigration+v1.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DBMigration+v1.swift"; sourceTree = "<group>"; };
456457
8DF1233D2330D9C900312A30 /* DBForexTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DBForexTests.swift; sourceTree = "<group>"; };
457-
8DF75CDB2322A85100130229 /* PlaygroundTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlaygroundTests.swift; sourceTree = "<group>"; };
458458
8DF85B1B22F046FA00F1C525 /* Error.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Error.swift; sourceTree = "<group>"; };
459459
8DF93B9722E757B4001B9412 /* APISentiment.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APISentiment.swift; sourceTree = "<group>"; };
460460
8DF93B9922E75C11001B9412 /* APISentimentTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APISentimentTests.swift; sourceTree = "<group>"; };
@@ -477,6 +477,7 @@
477477
isa = PBXFrameworksBuildPhase;
478478
buildActionMask = 2147483647;
479479
files = (
480+
8D2CC9E12477D45600B56599 /* Decimals in Frameworks */,
480481
8DC7FBF723E2F5D2002D7F5E /* Conbini in Frameworks */,
481482
);
482483
runOnlyForDeploymentPostprocessing = 0;
@@ -609,15 +610,6 @@
609610
path = session;
610611
sourceTree = "<group>";
611612
};
612-
8D8B3AB82299E8D900611153 /* playground */ = {
613-
isa = PBXGroup;
614-
children = (
615-
8DC185592403D4BE00D2AD54 /* General.playground */,
616-
8DF75CDB2322A85100130229 /* PlaygroundTests.swift */,
617-
);
618-
path = playground;
619-
sourceTree = "<group>";
620-
};
621613
8D94BA942316573900AFBA1E /* database */ = {
622614
isa = PBXGroup;
623615
children = (
@@ -795,18 +787,16 @@
795787
8DC4CA482149A6CE00344CBF /* utils */ = {
796788
isa = PBXGroup;
797789
children = (
798-
8DC4CA492149A6CE00344CBF /* Date.swift */,
799-
8D9FB786231F943C00D76B6A /* DateFormatter.swift */,
800-
8D88F5F8246C79D900743B2B /* UTC.swift */,
801-
8D911F6422ECF4CA0038E899 /* Decimal.swift */,
802-
8D3C262422E9FA020080D3C1 /* Collections.swift */,
790+
8DF85B1B22F046FA00F1C525 /* Error.swift */,
791+
8D19C51A2326459000F029B3 /* ErrorHelper.swift */,
792+
8D30D082232566D900D83E0A /* ErrorCodable.swift */,
803793
8D569217245FE63D00E9E621 /* c */,
794+
8DDB43AA2479704800A65CA5 /* CharacterSet.swift */,
795+
8D3C262422E9FA020080D3C1 /* Collections.swift */,
796+
8DDB43AD2479982800A65CA5 /* Foundation */,
804797
8DC4CA4B2149A6CE00344CBF /* Operators.swift */,
805798
8DE50471245AD09C001BD304 /* UnfairLock.swift */,
806799
8D9FB784231EDA6900D76B6A /* DebugDescriptable.swift */,
807-
8DF85B1B22F046FA00F1C525 /* Error.swift */,
808-
8D19C51A2326459000F029B3 /* ErrorHelper.swift */,
809-
8D30D082232566D900D83E0A /* ErrorCodable.swift */,
810800
);
811801
path = utils;
812802
sourceTree = "<group>";
@@ -934,7 +924,6 @@
934924
8DC4CA822149A6CE00344CBF /* tests */ = {
935925
isa = PBXGroup;
936926
children = (
937-
8D8B3AB82299E8D900611153 /* playground */,
938927
8DD468D322F1C70100134B67 /* Test.swift */,
939928
8DAEF08122F9994F005AB34C /* TestFabric.swift */,
940929
8DC4CAA62149A6CE00344CBF /* data */,
@@ -1071,6 +1060,17 @@
10711060
name = Products;
10721061
sourceTree = "<group>";
10731062
};
1063+
8DDB43AD2479982800A65CA5 /* Foundation */ = {
1064+
isa = PBXGroup;
1065+
children = (
1066+
8DC4CA492149A6CE00344CBF /* Date.swift */,
1067+
8D9FB786231F943C00D76B6A /* DateFormatter.swift */,
1068+
8D911F6422ECF4CA0038E899 /* Decimal.swift */,
1069+
8D88F5F8246C79D900743B2B /* UTC.swift */,
1070+
);
1071+
path = Foundation;
1072+
sourceTree = "<group>";
1073+
};
10741074
8DDBE9F923506F11001773D2 /* history */ = {
10751075
isa = PBXGroup;
10761076
children = (
@@ -1179,6 +1179,7 @@
11791179
name = "IG [macOS]";
11801180
packageProductDependencies = (
11811181
8DC7FBF623E2F5D2002D7F5E /* Conbini */,
1182+
8D2CC9E02477D45600B56599 /* Decimals */,
11821183
);
11831184
productName = IG;
11841185
productReference = 8DC4CBE12149A78700344CBF /* IG.framework */;
@@ -1212,7 +1213,7 @@
12121213
isa = PBXProject;
12131214
attributes = {
12141215
LastSwiftUpdateCheck = 1100;
1215-
LastUpgradeCheck = 1140;
1216+
LastUpgradeCheck = 1150;
12161217
TargetAttributes = {
12171218
8DA398B62338E3EA007B918F = {
12181219
CreatedOnToolsVersion = 11.0;
@@ -1241,6 +1242,7 @@
12411242
mainGroup = 8DC4CA332149A60900344CBF;
12421243
packageReferences = (
12431244
8DC7FBF323E2F5D2002D7F5E /* XCRemoteSwiftPackageReference "Conbini" */,
1245+
8D2CC9DF2477D45600B56599 /* XCRemoteSwiftPackageReference "Decimal64" */,
12441246
);
12451247
productRefGroup = 8DC4CBE22149A78700344CBF /* Products */;
12461248
projectDirPath = "";
@@ -1354,6 +1356,7 @@
13541356
8DE8A19F2349DE7E00031B1E /* Database.swift in Sources */,
13551357
8DE8A1A02349DE8200031B1E /* DBError.swift in Sources */,
13561358
8DE8A1A12349DF8D00031B1E /* DBChannel.swift in Sources */,
1359+
8DDB43AC2479704800A65CA5 /* CharacterSet.swift in Sources */,
13571360
8DE8A1A22349DF9100031B1E /* DBInternals.swift in Sources */,
13581361
8DE8A1A32349DF9600031B1E /* DBMigration.swift in Sources */,
13591362
8DE8A1A62349E33200031B1E /* DBMigration+v1.swift in Sources */,
@@ -1372,7 +1375,6 @@
13721375
files = (
13731376
8DF489DD234BA27A00DB85AA /* String.swift in Sources */,
13741377
8D0906A3236B4537005E7501 /* Date.swift in Sources */,
1375-
8D84AB1C233A029600DFAFFF /* PlaygroundTests.swift in Sources */,
13761378
8D80CFD02341E93000E63411 /* Test.swift in Sources */,
13771379
8D80CFD12341E93200E63411 /* TestFabric.swift in Sources */,
13781380
8D80CFCE2341E8D600E63411 /* TestAccount.swift in Sources */,
@@ -1489,6 +1491,7 @@
14891491
8D376D9F234C6300007D4A48 /* DBError.swift in Sources */,
14901492
8D376DA0234C6300007D4A48 /* DBChannel.swift in Sources */,
14911493
8D376DA1234C6300007D4A48 /* DBInternals.swift in Sources */,
1494+
8DDB43AB2479704800A65CA5 /* CharacterSet.swift in Sources */,
14921495
8D376D9D234C62F3007D4A48 /* Combine+DB.swift in Sources */,
14931496
8D376DA2234C6300007D4A48 /* DBMigration.swift in Sources */,
14941497
8D376DA3234C6300007D4A48 /* DBMigration+v1.swift in Sources */,
@@ -1507,7 +1510,6 @@
15071510
files = (
15081511
8D376DC4234C63D6007D4A48 /* String.swift in Sources */,
15091512
8D0906A2236B4533005E7501 /* Date.swift in Sources */,
1510-
8D376DA6234C6376007D4A48 /* PlaygroundTests.swift in Sources */,
15111513
8D376DA7234C6379007D4A48 /* Test.swift in Sources */,
15121514
8D376DA8234C637B007D4A48 /* TestFabric.swift in Sources */,
15131515
8D376DA9234C6387007D4A48 /* TestAccount.swift in Sources */,
@@ -1987,6 +1989,14 @@
19871989
/* End XCConfigurationList section */
19881990

19891991
/* Begin XCRemoteSwiftPackageReference section */
1992+
8D2CC9DF2477D45600B56599 /* XCRemoteSwiftPackageReference "Decimal64" */ = {
1993+
isa = XCRemoteSwiftPackageReference;
1994+
repositoryURL = "git@github.com:dehesa/Decimal64.git";
1995+
requirement = {
1996+
branch = develop;
1997+
kind = branch;
1998+
};
1999+
};
19902000
8DC7FBF323E2F5D2002D7F5E /* XCRemoteSwiftPackageReference "Conbini" */ = {
19912001
isa = XCRemoteSwiftPackageReference;
19922002
repositoryURL = "git@github.com:dehesa/Conbini.git";
@@ -1998,6 +2008,11 @@
19982008
/* End XCRemoteSwiftPackageReference section */
19992009

20002010
/* Begin XCSwiftPackageProductDependency section */
2011+
8D2CC9E02477D45600B56599 /* Decimals */ = {
2012+
isa = XCSwiftPackageProductDependency;
2013+
package = 8D2CC9DF2477D45600B56599 /* XCRemoteSwiftPackageReference "Decimal64" */;
2014+
productName = Decimals;
2015+
};
20012016
8DC7FBF423E2F5D2002D7F5E /* ConbiniForTesting */ = {
20022017
isa = XCSwiftPackageProductDependency;
20032018
package = 8DC7FBF323E2F5D2002D7F5E /* XCRemoteSwiftPackageReference "Conbini" */;

IG/IG.xcodeproj/xcshareddata/xcschemes/IG [iOS].xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1140"
3+
LastUpgradeVersion = "1150"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

IG/IG.xcodeproj/xcshareddata/xcschemes/IG [macOS].xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1140"
3+
LastUpgradeVersion = "1150"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

IG/sources/api/entities/APIAccount.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ extension IG.API.Account {
9797
public let trailingStops: Bool
9898

9999
/// Do not call! The only way to initialize is through `Decodable`.
100-
private init?() { fatalError("Unaccessible initializer") }
100+
@available(*, unavailable)
101+
private init?() { fatalError() }
101102

102103
private enum CodingKeys: String, CodingKey {
103104
case trailingStops = "trailingStopsEnabled"

IG/sources/api/entities/APIKey.swift

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import Foundation
2-
31
extension IG.API {
42
/// API development key.
53
public struct Key: RawRepresentable, ExpressibleByStringLiteral, LosslessStringConvertible, Hashable, Comparable, Codable {
@@ -29,7 +27,7 @@ extension IG.API {
2927
self.rawValue = rawValue
3028
}
3129

32-
public static func < (lhs: Self, rhs: Self) -> Bool {
30+
@_transparent public static func < (lhs: Self, rhs: Self) -> Bool {
3331
lhs.rawValue < rhs.rawValue
3432
}
3533

@@ -38,7 +36,7 @@ extension IG.API {
3836
try container.encode(self.rawValue)
3937
}
4038

41-
public var description: String {
39+
@_transparent public var description: String {
4240
self.rawValue
4341
}
4442
}
@@ -47,13 +45,7 @@ extension IG.API {
4745
extension IG.API.Key {
4846
/// Returns a Boolean indicating whether the raw value can represent an API key.
4947
private static func _validate(_ value: String) -> Bool {
50-
value.count == 40 && value.unicodeScalars.allSatisfy { _allowedSet.contains($0) }
48+
let allowedSet = Set.lowercaseANSI.union(Set.decimalDigits)
49+
return (value.count == 40) && value.allSatisfy { allowedSet.contains($0) }
5150
}
52-
53-
/// The allowed character set for the API key. It is used on validation.
54-
private static let _allowedSet: CharacterSet = {
55-
CharacterSet.decimalDigits.set {
56-
$0.formUnion(CharacterSet.lowercaseANSI)
57-
}
58-
}()
5951
}

IG/sources/api/entities/APIUser.swift

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -134,23 +134,21 @@ extension IG.API.User: IG.DebugDescriptable {
134134

135135
extension IG.API.User.Name {
136136
private static func _validate(_ value: String) -> Bool {
137-
let allowedRange = 1...30
138-
return allowedRange.contains(value.count) && value.unicodeScalars.allSatisfy { _allowedSet.contains($0) }
137+
let count = value.count
138+
guard count > 0, count < 31 else { return false }
139+
140+
let allowedSet = Set<Character>(arrayLiteral: "-", "_", #"\"#).set {
141+
$0.formUnion(Set.lowercaseANSI)
142+
$0.formUnion(Set.uppercaseANSI)
143+
$0.formUnion(Set.decimalDigits)
144+
}
145+
return value.allSatisfy { allowedSet.contains($0) }
139146
}
140-
141-
/// The allowed character set for username. It is used on validation.
142-
private static let _allowedSet: CharacterSet = {
143-
var result = CharacterSet(arrayLiteral: #"\"#, "-", "_")
144-
result.formUnion(CharacterSet.lowercaseANSI)
145-
result.formUnion(CharacterSet.uppercaseANSI)
146-
result.formUnion(CharacterSet.decimalDigits)
147-
return result
148-
}()
149147
}
150148

151149
extension IG.API.User.Password {
152150
private static func _validate(_ value: String) -> Bool {
153-
let allowedRange = 1...350
154-
return allowedRange.contains(value.count)
151+
let count = value.count
152+
return (count > 0) && (count < 351)
155153
}
156154
}

IG/sources/api/markets/APIMarket.swift

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -465,16 +465,18 @@ extension IG.API.Market.Instrument {
465465
public let exchangeRate: Decimal
466466
/// Is it the default currency?
467467
public let isDefault: Bool
468-
/// Do not call! The only way to initialize is through `Decodable`.
469-
private init?() { fatalError("Unaccessible initializer") }
468+
469+
@available(*, unavailable)
470+
private init?() { fatalError() }
470471
}
471472

472473
/// Market open and close times.
473474
public struct HourRange: Decodable {
474475
public let open: String
475476
public let close: String
476-
/// Do not call! The only way to initialize is through `Decodable`.
477-
private init?() { fatalError("Unaccessible initializer") }
477+
478+
@available(*, unavailable)
479+
private init?() { fatalError() }
478480

479481
private enum CodingKeys: String, CodingKey {
480482
case open = "openTime"
@@ -521,8 +523,9 @@ extension IG.API.Market.Instrument {
521523
public let minimum: Decimal
522524
/// Band maximum.
523525
public let maximum: Decimal?
524-
/// Do not call! The only way to initialize is through `Decodable`.
525-
private init?() { fatalError("Unaccessible initializer") }
526+
527+
@available(*, unavailable)
528+
private init?() { fatalError() }
526529

527530
private enum CodingKeys: String, CodingKey {
528531
case currencyCode = "currency"

0 commit comments

Comments
 (0)