From d4e49b5a59b84b291c6f1723a2c2a077af28f922 Mon Sep 17 00:00:00 2001 From: Jason Nam Date: Wed, 3 Feb 2016 10:54:49 +0900 Subject: [PATCH] Improved documentation --- Source/NJOPasswordRule.swift | 15 ++++++++++++--- Source/NJOPasswordValidator.swift | 8 +++++--- Source/Navajo.swift | 8 +++++--- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/Source/NJOPasswordRule.swift b/Source/NJOPasswordRule.swift index 411112b..798d041 100644 --- a/Source/NJOPasswordRule.swift +++ b/Source/NJOPasswordRule.swift @@ -31,9 +31,11 @@ import Foundation /// By adopting NJOPasswordRule protocol you can build your own rules. public protocol NJOPasswordRule { - /// Evaluating the password - /// - Parameter password: Password string to be evaluated - /// - Returns: true is considered to be failed and false is passed. + /** + Evaluating the password + - Parameter password: Password string to be evaluated + - Returns: true is considered to be failed and false is passed. + */ func evaluateWithString(string: String) -> Bool /// Error description func localizedErrorDescription() -> String @@ -55,6 +57,7 @@ public enum NJORequiredCharacterRulePreset { public class NJOAllowedCharacterRule: NSObject, NJOPasswordRule { private var disallowedCharacters: NSCharacterSet! = nil + /// Initialize with an NSCharacterSet object. public convenience init(characterSet: NSCharacterSet) { self.init() disallowedCharacters = characterSet.invertedSet @@ -81,6 +84,7 @@ public class NJORequiredCharacterRule: NSObject, NJOPasswordRule { private var _preset: NJORequiredCharacterRulePreset! = nil private var requiredCharacterSet: NSCharacterSet! = nil + /// Initialize with an NJORequiredCharacterRulePreset object. public convenience init(preset: NJORequiredCharacterRulePreset) { self.init() @@ -100,6 +104,7 @@ public class NJORequiredCharacterRule: NSObject, NJOPasswordRule { } } + /// Initialize with an NSCharacterSet object. public convenience init(characterSet: NSCharacterSet) { self.init() requiredCharacterSet = characterSet @@ -163,6 +168,7 @@ public class NJODictionaryWordRule: NSObject, NJOPasswordRule { public class NJOLengthRule: NSObject, NJOPasswordRule { private var _range: NSRange! = nil + /// Initialize with minimum and maximum values. public convenience init(min: Int, max: Int) { self.init() _range = NSMakeRange(min, max - min + 1) @@ -188,6 +194,7 @@ public class NJOLengthRule: NSObject, NJOPasswordRule { public class NJOPredicateRule: NSObject, NJOPasswordRule { private var _predicate: NSPredicate! = nil + /// Initialize with an NSPredicate object. public convenience init(predicate: NSPredicate) { self.init() _predicate = predicate @@ -213,6 +220,7 @@ public class NJOPredicateRule: NSObject, NJOPasswordRule { public class NJORegularExpressionRule: NSObject, NJOPasswordRule { private var _regularExpression: NSRegularExpression! = nil + /// Initialize with an NSRegularExpression object. public convenience init(regularExpression: NSRegularExpression) { self.init() _regularExpression = regularExpression @@ -238,6 +246,7 @@ public class NJORegularExpressionRule: NSObject, NJOPasswordRule { public class NJOBlockRule: NSObject, NJOPasswordRule { private var _evaluation: (String -> Bool)! = nil + /// Initialize with a Block. public convenience init(evaluation: String -> Bool) { self.init() _evaluation = evaluation diff --git a/Source/NJOPasswordValidator.swift b/Source/NJOPasswordValidator.swift index 3e54941..e50ecfc 100644 --- a/Source/NJOPasswordValidator.swift +++ b/Source/NJOPasswordValidator.swift @@ -44,9 +44,11 @@ public class NJOPasswordValidator: NSObject { return NJOLengthRule(min: 6, max: 24) } - /// Executes validation with a password and returns failing rules. - /// - Parameter password: Password string to be validated - /// - Returns: Failing rules. nil if all of the rules are passed. + /** + Executes validation with a password and returns failing rules. + - Parameter password: Password string to be validated + - Returns: Failing rules. nil if all of the rules are passed. + */ public func validatePassword(password: String) -> [NJOPasswordRule]? { var failingRules: [NJOPasswordRule] = [] diff --git a/Source/Navajo.swift b/Source/Navajo.swift index cc84ebf..12a49b8 100644 --- a/Source/Navajo.swift +++ b/Source/Navajo.swift @@ -42,9 +42,11 @@ public enum NJOPasswordStrength { /// Navajo validates strength of passwords. public class Navajo: NSObject { - /// Gets strength of a password. - /// - Parameter password: Password string to be calculated - /// - Returns: Level of strength in NJOPasswordStrength + /** + Gets strength of a password. + - Parameter password: Password string to be calculated + - Returns: Level of strength in NJOPasswordStrength + */ public class func strengthOfPassword(password: String) -> NJOPasswordStrength { return NJOPasswordStrengthForEntropy(NJOEntropyForString(password)) }