diff --git a/SwiftValidator/Rules/ExactLengthRule.swift b/SwiftValidator/Rules/ExactLengthRule.swift
index c9aae6d..4798bd9 100644
--- a/SwiftValidator/Rules/ExactLengthRule.swift
+++ b/SwiftValidator/Rules/ExactLengthRule.swift
@@ -36,7 +36,7 @@ public class ExactLengthRule : Rule {
- returns: A boolean value. True if validation is successful; False if validation fails.
*/
public func validate(_ value: String) -> Bool {
- return value.characters.count == length
+ return value.count == length
}
/**
diff --git a/SwiftValidator/Rules/FloatRule.swift b/SwiftValidator/Rules/FloatRule.swift
index cf30557..669c0e0 100644
--- a/SwiftValidator/Rules/FloatRule.swift
+++ b/SwiftValidator/Rules/FloatRule.swift
@@ -34,7 +34,7 @@ public class FloatRule:Rule {
public func validate(_ value: String) -> Bool {
let regex = try? NSRegularExpression(pattern: "^[-+]?(\\d*[.])?\\d+$", options: [])
if let regex = regex {
- let match = regex.numberOfMatches(in: value, options: [], range: NSRange(location: 0, length: value.characters.count))
+ let match = regex.numberOfMatches(in: value, options: [], range: NSRange(location: 0, length: value.count))
return match == 1
}
return false
diff --git a/SwiftValidator/Rules/FullNameRule.swift b/SwiftValidator/Rules/FullNameRule.swift
index b9894e0..de94c49 100644
--- a/SwiftValidator/Rules/FullNameRule.swift
+++ b/SwiftValidator/Rules/FullNameRule.swift
@@ -31,7 +31,7 @@ public class FullNameRule : Rule {
- returns: A boolean value. True if validation is successful; False if validation fails.
*/
public func validate(_ value: String) -> Bool {
- let nameArray: [String] = value.characters.split { $0 == " " }.map { String($0) }
+ let nameArray: [String] = value.split { $0 == " " }.map { String($0) }
return nameArray.count >= 2
}
diff --git a/SwiftValidator/Rules/ISBNRule.swift b/SwiftValidator/Rules/ISBNRule.swift
index 6f8654f..4d39b0e 100644
--- a/SwiftValidator/Rules/ISBNRule.swift
+++ b/SwiftValidator/Rules/ISBNRule.swift
@@ -38,7 +38,7 @@ public class ISBNRule: Rule {
fatalError("Invalid ISBN sanitizing regex")
}
- let sanitized = regex.stringByReplacingMatches(in: value, options: [], range: NSMakeRange(0, value.characters.count), withTemplate: "")
+ let sanitized = regex.stringByReplacingMatches(in: value, options: [], range: NSMakeRange(0, value.count), withTemplate: "")
return ISBN10Validator().verify(sanitized) || ISBN13Validator().verify(sanitized)
}
@@ -140,15 +140,15 @@ private struct ISBN10Validator: ISBNValidator {
var checksum = 0
for i in 0..<9 {
- if let intCharacter = Int(String(input[input.characters.index(input.startIndex, offsetBy: i)])) {
+ if let intCharacter = Int(String(input[input.index(input.startIndex, offsetBy: i)])) {
checksum += (i + 1) * intCharacter
}
}
- if (input[input.characters.index(input.startIndex, offsetBy: 9)] == "X") {
+ if (input[input.index(input.startIndex, offsetBy: 9)] == "X") {
checksum += 10 * 10
} else {
- if let intCharacter = Int(String(input[input.characters.index(input.startIndex, offsetBy: 9)])) {
+ if let intCharacter = Int(String(input[input.index(input.startIndex, offsetBy: 9)])) {
checksum += 10 * intCharacter
}
}
@@ -176,13 +176,13 @@ private struct ISBN13Validator: ISBNValidator {
var checksum = 0
for i in 0..<12 {
- if let intCharacter = Int(String(input[input.characters.index(input.startIndex, offsetBy: i)])) {
+ if let intCharacter = Int(String(input[input.index(input.startIndex, offsetBy: i)])) {
print("\(factor[i%2]) * \(intCharacter)")
checksum += factor[i % 2] * intCharacter
}
}
- if let lastInt = Int(String(input[input.characters.index(input.startIndex, offsetBy: 12)])) {
+ if let lastInt = Int(String(input[input.index(input.startIndex, offsetBy: 12)])) {
return (lastInt - ((10 - (checksum % 10)) % 10) == 0)
}
diff --git a/SwiftValidator/Rules/MaxLengthRule.swift b/SwiftValidator/Rules/MaxLengthRule.swift
index 57d9b7b..0c65d81 100644
--- a/SwiftValidator/Rules/MaxLengthRule.swift
+++ b/SwiftValidator/Rules/MaxLengthRule.swift
@@ -37,7 +37,7 @@ public class MaxLengthRule: Rule {
- returns: A boolean value. True if validation is successful; False if validation fails.
*/
public func validate(_ value: String) -> Bool {
- return value.characters.count <= DEFAULT_LENGTH
+ return value.count <= DEFAULT_LENGTH
}
/**
diff --git a/SwiftValidator/Rules/MinLengthRule.swift b/SwiftValidator/Rules/MinLengthRule.swift
index d9e161c..b83166d 100644
--- a/SwiftValidator/Rules/MinLengthRule.swift
+++ b/SwiftValidator/Rules/MinLengthRule.swift
@@ -38,7 +38,7 @@ public class MinLengthRule: Rule {
- returns: A boolean value. True if validation is successful; False if validation fails.
*/
public func validate(_ value: String) -> Bool {
- return value.characters.count >= DEFAULT_LENGTH
+ return value.count >= DEFAULT_LENGTH
}
/**
diff --git a/Validator.xcodeproj/project.pbxproj b/Validator.xcodeproj/project.pbxproj
index 17b420c..e0ff2e2 100644
--- a/Validator.xcodeproj/project.pbxproj
+++ b/Validator.xcodeproj/project.pbxproj
@@ -396,7 +396,7 @@
attributes = {
LastSwiftMigration = 0700;
LastSwiftUpdateCheck = 0700;
- LastUpgradeCheck = 0800;
+ LastUpgradeCheck = 0930;
ORGANIZATIONNAME = jpotts18;
TargetAttributes = {
62D1AE161A1E6D4400E4DFF8 = {
@@ -584,14 +584,22 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -619,6 +627,7 @@
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
+ SWIFT_VERSION = 4.0;
};
name = Debug;
};
@@ -630,14 +639,22 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -656,6 +673,8 @@
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
+ SWIFT_COMPILATION_MODE = wholemodule;
+ SWIFT_VERSION = 4.0;
VALIDATE_PRODUCT = YES;
};
name = Release;
@@ -668,7 +687,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "me.jeffpotter.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
- SWIFT_VERSION = 3.0;
+ SWIFT_VERSION = 4.0;
};
name = Debug;
};
@@ -681,7 +700,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "me.jeffpotter.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
- SWIFT_VERSION = 3.0;
+ SWIFT_VERSION = 4.0;
};
name = Release;
};
@@ -697,7 +716,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "me.jeffpotter.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
- SWIFT_VERSION = 3.0;
+ SWIFT_VERSION = 4.1;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Validator.app/Validator";
};
name = Debug;
@@ -710,7 +729,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "me.jeffpotter.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
- SWIFT_VERSION = 3.0;
+ SWIFT_VERSION = 4.1;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Validator.app/Validator";
};
name = Release;
@@ -718,6 +737,7 @@
FB465CCC1B9884F400398388 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ CODE_SIGN_IDENTITY = "";
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEFINES_MODULE = YES;
@@ -735,7 +755,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "me.jeffpotter.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
- SWIFT_VERSION = 3.0;
+ SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
@@ -745,6 +765,7 @@
FB465CCD1B9884F400398388 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ CODE_SIGN_IDENTITY = "";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
@@ -760,7 +781,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
- SWIFT_VERSION = 3.0;
+ SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
@@ -785,7 +806,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.levous.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
- SWIFT_VERSION = 3.0;
+ SWIFT_VERSION = 4.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Validator.app/Validator";
};
name = Debug;
@@ -806,7 +827,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.levous.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
- SWIFT_VERSION = 3.0;
+ SWIFT_VERSION = 4.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Validator.app/Validator";
};
name = Release;
diff --git a/Validator.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Validator.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
new file mode 100644
index 0000000..18d9810
--- /dev/null
+++ b/Validator.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
@@ -0,0 +1,8 @@
+
+
+
+
+ IDEDidComputeMac32BitWarning
+
+
+
diff --git a/Validator.xcodeproj/xcshareddata/xcschemes/SwiftValidator.xcscheme b/Validator.xcodeproj/xcshareddata/xcschemes/SwiftValidator.xcscheme
index b8b0c59..d6ae464 100644
--- a/Validator.xcodeproj/xcshareddata/xcschemes/SwiftValidator.xcscheme
+++ b/Validator.xcodeproj/xcshareddata/xcschemes/SwiftValidator.xcscheme
@@ -1,6 +1,6 @@
+ codeCoverageEnabled = "YES"
+ shouldUseLaunchSchemeArgsEnv = "YES">
diff --git a/Validator.xcodeproj/xcshareddata/xcschemes/Validator.xcscheme b/Validator.xcodeproj/xcshareddata/xcschemes/Validator.xcscheme
index e9d5ba4..5da1196 100644
--- a/Validator.xcodeproj/xcshareddata/xcschemes/Validator.xcscheme
+++ b/Validator.xcodeproj/xcshareddata/xcschemes/Validator.xcscheme
@@ -1,6 +1,6 @@