Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added error propagation and project fixes #18

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
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
7 changes: 2 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
osx_image: xcode9.2
language: objective-c
before_script:
- export LANG=en_US.UTF-8
before_install:
- brew update
- brew uninstall xctool
- brew install xctool
script:
- xctool -project KiteJSONValidator.xcodeproj -scheme KiteJSONValidatorTests -sdk iphonesimulator test ONLY_ACTIVE_ARCH=NO
- set -o pipefail && xcodebuild clean test -project KiteJSONValidator.xcodeproj -scheme KiteJSONValidatorTests -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6,OS=11.2' ONLY_ACTIVE_ARCH=NO | xcpretty
6 changes: 3 additions & 3 deletions KiteJSONValidator.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ Pod::Spec.new do |s|
s.homepage = "https://github.com/samskiter/KiteJSONValidator"
s.license = "MIT"
s.authors = { "Sam Duke" => "[email protected]" }
s.version = "0.2.2"
s.source = { :git => "https://github.com/samskiter/KiteJSONValidator.git", :tag => "v#{s.version}"}
s.platform = :ios, '7.0'
s.version = "0.2.3"
s.source = { :git => "https://github.com/samskiter/KiteJSONValidator.git", :tag => "v#{s.version}" }
s.platforms = { :ios => '7.0', :osx => '10.9' }
s.requires_arc = true
s.source_files = "Sources/*.{h,m}"
s.xcconfig = {
Expand Down
57 changes: 52 additions & 5 deletions KiteJSONValidator.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
isa = PBXProject;
attributes = {
CLASSPREFIX = Kite;
LastUpgradeCheck = 0610;
LastUpgradeCheck = 0920;
ORGANIZATIONNAME = KiteJSONValidator;
};
buildConfigurationList = 67B6B112188C32E800E1630A /* Build configuration list for PBXProject "KiteJSONValidator" */;
Expand Down Expand Up @@ -301,6 +301,7 @@
ALWAYS_SEARCH_USER_PATHS = NO;
COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = "Resources/KiteJSONValidator-Info.plist";
PRODUCT_BUNDLE_IDENTIFIER = "com.kitejsonvalidator.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = KiteJSONValidator;
SKIP_INSTALL = YES;
WRAPPER_EXTENSION = bundle;
Expand All @@ -313,6 +314,7 @@
ALWAYS_SEARCH_USER_PATHS = NO;
COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = "Resources/KiteJSONValidator-Info.plist";
PRODUCT_BUNDLE_IDENTIFIER = "com.kitejsonvalidator.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = KiteJSONValidator;
SKIP_INSTALL = YES;
WRAPPER_EXTENSION = bundle;
Expand All @@ -322,14 +324,36 @@
67B6B113188C32E800E1630A /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
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_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_ATOMIC_PROPERTIES = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES;
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;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = YES;
GCC_WARN_STRICT_SELECTOR_MATCH = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos";
Expand All @@ -339,14 +363,35 @@
67B6B114188C32E800E1630A /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
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_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_ATOMIC_PROPERTIES = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES;
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;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = YES;
GCC_WARN_STRICT_SELECTOR_MATCH = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos";
};
Expand Down Expand Up @@ -400,7 +445,8 @@
GCC_WARN_UNUSED_LABEL = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_FILE = "Tests/Tests-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
PRODUCT_BUNDLE_IDENTIFIER = "samskiter.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = xctest;
};
Expand Down Expand Up @@ -448,7 +494,8 @@
GCC_WARN_UNUSED_LABEL = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_FILE = "Tests/Tests-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
PRODUCT_BUNDLE_IDENTIFIER = "samskiter.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
VALIDATE_PRODUCT = YES;
WRAPPER_EXTENSION = xctest;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0610"
LastUpgradeVersion = "0920"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -23,21 +23,26 @@
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
Expand All @@ -52,10 +57,10 @@
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0610"
LastUpgradeVersion = "0920"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -37,10 +37,11 @@
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
Expand All @@ -53,15 +54,19 @@
</BuildableReference>
</TestableReference>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
Expand All @@ -76,10 +81,10 @@
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
Expand Down
2 changes: 1 addition & 1 deletion Resources/KiteJSONValidator-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>com.kitejsonvalidator.${PRODUCT_NAME:rfc1034identifier}</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down
25 changes: 15 additions & 10 deletions Sources/KiteJSONValidator.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@protocol KiteJSONSchemaRefDelegate;

@interface KiteJSONValidator : NSObject

@property (nonatomic, weak) id<KiteJSONSchemaRefDelegate> delegate;
@property (nonatomic, weak, nullable) id<KiteJSONSchemaRefDelegate> delegate;

/**
Validates json against a draft4 schema.
Expand All @@ -22,9 +24,9 @@
@param schemaData The draft4 JSON schema to validate against
@return Whether the json is validated.
*/
-(BOOL)validateJSONData:(NSData*)jsonData withSchemaData:(NSData*)schemaData;
-(BOOL)validateJSONInstance:(id)json withSchema:(NSDictionary*)schema;
-(BOOL)validateJSONInstance:(id)json withSchemaData:(NSData*)schemaData;
-(BOOL)validateJSONData:(NSData*)jsonData withSchemaData:(NSData*)schemaData error:(NSError **)error;
-(BOOL)validateJSONInstance:(id)json withSchema:(NSDictionary*)schema error:(NSError **)error;
-(BOOL)validateJSONInstance:(id)json withSchemaData:(NSData*)schemaData error:(NSError **)error;
//TODO:add an interface to add a schema with a key, allowing a schema to only be validated once and then reused

/**
Expand All @@ -35,7 +37,7 @@

@return Whether the reference schema was successfully added.
*/
-(BOOL)addRefSchemaData:(NSData*)schemaData atURL:(NSURL*)url;
-(BOOL)addRefSchemaData:(NSData*)schemaData atURL:(NSURL*)url error:(NSError **)error;

/**
Used for adding an ENTIRE document to the list of reference schemas - the URL should therefore be fragmentless.
Expand All @@ -46,7 +48,7 @@

@return Whether the reference schema was successfully added.
*/
-(BOOL)addRefSchemaData:(NSData*)schemaData atURL:(NSURL*)url validateSchema:(BOOL)shouldValidateSchema;
-(BOOL)addRefSchemaData:(NSData*)schemaData atURL:(NSURL*)url validateSchema:(BOOL)shouldValidateSchema error:(NSError **)error;

/**
Used for adding an ENTIRE document to the list of reference schemas - the URL should therefore be fragmentless.
Expand All @@ -56,7 +58,7 @@

@return Whether the reference schema was successfully added.
*/
-(BOOL)addRefSchema:(NSDictionary*)schema atURL:(NSURL*)url;
-(BOOL)addRefSchema:(NSDictionary*)schema atURL:(NSURL*)url error:(NSError **)error;

/**
Used for adding an ENTIRE document to the list of reference schemas - the URL should therefore be fragmentless.
Expand All @@ -67,13 +69,16 @@

@return Whether the reference schema was successfully added.
*/
-(BOOL)addRefSchema:(NSDictionary *)schema atURL:(NSURL *)url validateSchema:(BOOL)shouldValidateSchema;
-(BOOL)addRefSchema:(NSDictionary *)schema atURL:(NSURL *)url validateSchema:(BOOL)shouldValidateSchema error:(NSError **)error;

@end

@protocol KiteJSONSchemaRefDelegate <NSObject>

-(NSData*)schemaValidator:(KiteJSONValidator*)validator requiresSchemaDataForRefURL:(NSURL*)refURL;
-(NSDictionary*)schemaValidator:(KiteJSONValidator*)validator requiresSchemaForRefURL:(NSURL*)refURL;
@optional
-(nullable NSData*)schemaValidator:(KiteJSONValidator*)validator requiresSchemaDataForRefURL:(NSURL*)refURL;
-(nullable NSDictionary*)schemaValidator:(KiteJSONValidator*)validator requiresSchemaForRefURL:(NSURL*)refURL;

@end

NS_ASSUME_NONNULL_END
Loading