Skip to content
This repository was archived by the owner on May 11, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 53 additions & 57 deletions NGRValidator.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1204,7 +1204,6 @@
022228371E85061300CE4399 /* Frameworks */,
022228381E85061300CE4399 /* Resources */,
AF5558FC46B842826F129969 /* [CP] Embed Pods Frameworks */,
3CD078A403537712C21E98ED /* [CP] Copy Pods Resources */,
);
buildRules = (
);
Expand Down Expand Up @@ -1245,7 +1244,6 @@
5E5C0A051A498164002D3E72 /* Frameworks */,
5E5C0A061A498164002D3E72 /* Resources */,
F8EBD14E051812362FFBBB34 /* [CP] Embed Pods Frameworks */,
EB22D3D5F363FF44F150E789 /* [CP] Copy Pods Resources */,
);
buildRules = (
);
Expand All @@ -1267,7 +1265,8 @@
TargetAttributes = {
020A96B91E82D29100DF6E12 = {
CreatedOnToolsVersion = 8.2.1;
LastSwiftMigration = 0820;
DevelopmentTeam = WCB4RRJ4WD;
LastSwiftMigration = 1020;
ProvisioningStyle = Automatic;
};
022227AB1E85046A00CE4399 = {
Expand All @@ -1281,19 +1280,18 @@
};
5E5C09EE1A498164002D3E72 = {
CreatedOnToolsVersion = 6.1;
DevelopmentTeam = SK8PDF7SG9;
LastSwiftMigration = 0820;
DevelopmentTeam = WCB4RRJ4WD;
LastSwiftMigration = 1010;
};
5E5C0A071A498164002D3E72 = {
CreatedOnToolsVersion = 6.1;
DevelopmentTeam = SK8PDF7SG9;
LastSwiftMigration = 0820;
LastSwiftMigration = 1020;
};
};
};
buildConfigurationList = 5E5C09EA1A498164002D3E72 /* Build configuration list for PBXProject "NGRValidator" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Expand Down Expand Up @@ -1423,34 +1421,28 @@
shellPath = /bin/sh;
shellScript = ./Scripts/generate_emojis.sh;
};
3CD078A403537712C21E98ED /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-NGRValidatorTests-MacOS/Pods-NGRValidatorTests-MacOS-resources.sh\"\n";
showEnvVarsInLog = 0;
};
AF5558FC46B842826F129969 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-NGRValidatorTests-MacOS/Pods-NGRValidatorTests-MacOS-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/Expecta-macOS/Expecta.framework",
"${BUILT_PRODUCTS_DIR}/Nimble-macOS/Nimble.framework",
"${BUILT_PRODUCTS_DIR}/Quick-macOS/Quick.framework",
"${BUILT_PRODUCTS_DIR}/Specta-macOS/Specta.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Expecta.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Nimble.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Quick.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Specta.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-NGRValidatorTests-MacOS/Pods-NGRValidatorTests-MacOS-frameworks.sh\"\n";
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-NGRValidatorTests-MacOS/Pods-NGRValidatorTests-MacOS-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
C1017983269E679841E91375 /* [CP] Check Pods Manifest.lock */ = {
Expand All @@ -1459,13 +1451,16 @@
files = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-NGRValidatorTests-iOS-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
D3727EEA42D1670738BB7901 /* [CP] Check Pods Manifest.lock */ = {
Expand All @@ -1474,28 +1469,16 @@
files = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-NGRValidatorTests-MacOS-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
EB22D3D5F363FF44F150E789 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-NGRValidatorTests-iOS/Pods-NGRValidatorTests-iOS-resources.sh\"\n";
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
F8EBD14E051812362FFBBB34 /* [CP] Embed Pods Frameworks */ = {
Expand All @@ -1504,13 +1487,22 @@
files = (
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-NGRValidatorTests-iOS/Pods-NGRValidatorTests-iOS-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/Expecta-iOS/Expecta.framework",
"${BUILT_PRODUCTS_DIR}/Nimble-iOS/Nimble.framework",
"${BUILT_PRODUCTS_DIR}/Quick-iOS/Quick.framework",
"${BUILT_PRODUCTS_DIR}/Specta-iOS/Specta.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Expecta.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Nimble.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Quick.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Specta.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-NGRValidatorTests-iOS/Pods-NGRValidatorTests-iOS-frameworks.sh\"\n";
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-NGRValidatorTests-iOS/Pods-NGRValidatorTests-iOS-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
Expand Down Expand Up @@ -1729,7 +1721,7 @@
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = dwarf;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
DEVELOPMENT_TEAM = WCB4RRJ4WD;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
Expand All @@ -1743,7 +1735,7 @@
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos";
SWIFT_INSTALL_OBJC_HEADER = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
VALID_ARCHS = "arm64 armv7 armv7s";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand All @@ -1762,7 +1754,7 @@
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
DEVELOPMENT_TEAM = WCB4RRJ4WD;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
Expand All @@ -1775,7 +1767,7 @@
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos";
SWIFT_INSTALL_OBJC_HEADER = YES;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
VALID_ARCHS = "arm64 armv7 armv7s";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand All @@ -1788,7 +1780,7 @@
CLANG_ANALYZER_NONNULL = YES;
CLANG_ENABLE_MODULES = YES;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CODE_SIGN_IDENTITY = "";
CODE_SIGN_IDENTITY = "Mac Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = dwarf;
Expand All @@ -1809,7 +1801,7 @@
SUPPORTED_PLATFORMS = macosx;
SWIFT_INSTALL_OBJC_HEADER = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.2;
VALID_ARCHS = "x86_64 i386";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand Down Expand Up @@ -1843,7 +1835,7 @@
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = macosx;
SWIFT_INSTALL_OBJC_HEADER = YES;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.2;
VALID_ARCHS = "x86_64 i386";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand Down Expand Up @@ -1875,7 +1867,7 @@
SDKROOT = macosx;
SWIFT_OBJC_BRIDGING_HEADER = "NGRValidatorTests/NGRValidatorTests-MacOS-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand Down Expand Up @@ -1904,7 +1896,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SWIFT_OBJC_BRIDGING_HEADER = "NGRValidatorTests/NGRValidatorTests-MacOS-Bridging-Header.h";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand Down Expand Up @@ -2010,6 +2002,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = WCB4RRJ4WD;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = NGRValidator/NGRValidator.pch;
INFOPLIST_FILE = "$(SRCROOT)/NGRValidator/Demo/Info.plist";
Expand All @@ -2020,7 +2013,8 @@
PROVISIONING_PROFILE = "";
SWIFT_OBJC_BRIDGING_HEADER = "NGRValidator/NGRValidatorDemo-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = 1;
};
name = Debug;
Expand All @@ -2035,6 +2029,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = WCB4RRJ4WD;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = NGRValidator/NGRValidator.pch;
INFOPLIST_FILE = "$(SRCROOT)/NGRValidator/Demo/Info.plist";
Expand All @@ -2044,7 +2039,8 @@
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
SWIFT_OBJC_BRIDGING_HEADER = "NGRValidator/NGRValidatorDemo-Bridging-Header.h";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = 1;
};
name = Release;
Expand All @@ -2057,7 +2053,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEVELOPMENT_TEAM = SK8PDF7SG9;
DEVELOPMENT_TEAM = "";
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
Expand All @@ -2080,7 +2076,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "NGRValidatorTests/NGRValidatorTests-iOS-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -2091,7 +2087,7 @@
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
DEVELOPMENT_TEAM = SK8PDF7SG9;
DEVELOPMENT_TEAM = "";
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
Expand All @@ -2109,7 +2105,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.netguru.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "NGRValidatorTests/NGRValidatorTests-iOS-Bridging-Header.h";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
4 changes: 2 additions & 2 deletions NGRValidator/Demo/NGRSwiftViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ final class NGRSwiftViewController: UIViewController {
validateButton.addTarget(self, action: #selector(validateAction), for: .touchUpInside)
}

func validateAction() {
@objc func validateAction() {

let user = User(name: nameTextField.text!, password: passwordTextField.text!)

Expand All @@ -74,7 +74,7 @@ final class NGRSwiftViewController: UIViewController {
NGRPropertyValidator(property: "nonExistent")?.is.required().to.have.minLength(5).msgTooShort("should have at least 5 signs"),
NGRPropertyValidator(property: "birthDate")?.to.be.earlierThan(Date()).msgNotEarlierThan("should happen in the past"),
NGRPropertyValidator(property: "attachment")?.is.required().to.be.image().msgTooShort("should have at least 5 signs").when({ false }),
].flatMap { $0 }
].compactMap { $0 }
}

guard let errors = validationErrors, !errors.isEmpty else { return }
Expand Down
2 changes: 1 addition & 1 deletion NGRValidator/NGRValidator/NGRRuntime.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fileprivate extension Mirror {
}

func properties() -> [String] {
let childProperties = children.flatMap { $0.label }
let childProperties = children.compactMap { $0.label }
let superProperties = superclassMirror?.properties() ?? []

return [childProperties, superProperties].flatMap { $0 }
Expand Down
4 changes: 2 additions & 2 deletions NGRValidator/NGRValidator/NGRValidator+Swift.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public extension NGRValidator {
*
**/

public static func validate(model: Any, tillFirstError: Bool = false, delegate: NGRMessaging? = nil, scenario: String? = nil, rules: NGRRules) -> [Error]? {
static func validate(model: Any, tillFirstError: Bool = false, delegate: NGRMessaging? = nil, scenario: String? = nil, rules: NGRRules) -> [Error]? {

guard let validators = rules()?.sorted(by: { $0.priority > $1.priority }) else {
print("Lack of validation rules in \(model) model. Validation couldn't be processed.")
Expand Down Expand Up @@ -56,7 +56,7 @@ public extension NGRValidator {
return tillFirstError ? nil : errors
}

public static func validate(value: Any, named: String, rules: @escaping (NGRPropertyValidator?) -> Void) -> Error? {
static func validate(value: Any, named: String, rules: @escaping (NGRPropertyValidator?) -> Void) -> Error? {
let inspector = NGRRuntimeInspector(model: value)
guard inspector.isClassOrStruct() else {
fatalError("Validation is supported only for Structs or Classes")
Expand Down
4 changes: 2 additions & 2 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ inhibit_all_warnings!
def testing_pods
pod 'Expecta', '1.0.5'
pod 'Specta', '1.0.5'
pod 'Quick', '1.1.0'
pod 'Nimble', '6.1.0'
pod 'Quick'
pod 'Nimble'
end

target 'NGRValidatorTests-iOS' do
Expand Down
Loading