diff --git a/Validator.xcodeproj/project.pbxproj b/Validator.xcodeproj/project.pbxproj index 61bb899..f0feb2f 100644 --- a/Validator.xcodeproj/project.pbxproj +++ b/Validator.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 623F29941AD836E6005B26CB /* MaxLengthRule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 623F29931AD836E6005B26CB /* MaxLengthRule.swift */; }; 628637261AAA474B00BC8FCF /* MinLengthRule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 628637251AAA474B00BC8FCF /* MinLengthRule.swift */; }; 628637281AAA49E300BC8FCF /* ConfirmRule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 628637271AAA49E300BC8FCF /* ConfirmRule.swift */; }; 62D1AE1D1A1E6D4400E4DFF8 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62D1AE1C1A1E6D4400E4DFF8 /* AppDelegate.swift */; }; @@ -38,6 +39,7 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 623F29931AD836E6005B26CB /* MaxLengthRule.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaxLengthRule.swift; sourceTree = ""; }; 628637251AAA474B00BC8FCF /* MinLengthRule.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MinLengthRule.swift; sourceTree = ""; }; 628637271AAA49E300BC8FCF /* ConfirmRule.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConfirmRule.swift; sourceTree = ""; }; 62D1AE171A1E6D4400E4DFF8 /* Validator.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Validator.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -159,6 +161,7 @@ 62DC8D661AAA42700095DFA7 /* Rules */ = { isa = PBXGroup; children = ( + 623F29931AD836E6005B26CB /* MaxLengthRule.swift */, 628637251AAA474B00BC8FCF /* MinLengthRule.swift */, 62DC8D641AAA42520095DFA7 /* Rule.swift */, 62DC8D691AAA42CE0095DFA7 /* EmailRule.swift */, @@ -286,6 +289,7 @@ 628637261AAA474B00BC8FCF /* MinLengthRule.swift in Sources */, 62DC8D711AAA43110095DFA7 /* ZipCodeRule.swift in Sources */, 62D1AE521A1E6FF800E4DFF8 /* ValidationRule.swift in Sources */, + 623F29941AD836E6005B26CB /* MaxLengthRule.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Validator/MaxLengthRule.swift b/Validator/MaxLengthRule.swift index ba4fa1c..a659f3b 100644 --- a/Validator/MaxLengthRule.swift +++ b/Validator/MaxLengthRule.swift @@ -7,21 +7,21 @@ import Foundation -class MaxLengthRule: Rule { +public class MaxLengthRule: Rule { private var DEFAULT_MAX_LENGTH: Int = 16 - init(){} + public init(){} - init(length: Int){ + public init(length: Int){ self.DEFAULT_MAX_LENGTH = length } - func validate(value: String) -> Bool { + public func validate(value: String) -> Bool { return countElements(value) <= DEFAULT_MAX_LENGTH } - func errorMessage() -> String { + public func errorMessage() -> String { return "Must be at most \(DEFAULT_MAX_LENGTH) characters long" } }