Skip to content

Commit

Permalink
Improved documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonnam committed Feb 3, 2016
1 parent 1e37949 commit d4e49b5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
15 changes: 12 additions & 3 deletions Source/NJOPasswordRule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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()

Expand All @@ -100,6 +104,7 @@ public class NJORequiredCharacterRule: NSObject, NJOPasswordRule {
}
}

/// Initialize with an NSCharacterSet object.
public convenience init(characterSet: NSCharacterSet) {
self.init()
requiredCharacterSet = characterSet
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
8 changes: 5 additions & 3 deletions Source/NJOPasswordValidator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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] = []

Expand Down
8 changes: 5 additions & 3 deletions Source/Navajo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down

0 comments on commit d4e49b5

Please sign in to comment.