Skip to content

Commit

Permalink
Added examples
Browse files Browse the repository at this point in the history
Added examples to- and improved description of- the predefined checks.
  • Loading branch information
havardt authored Jun 8, 2019
1 parent 6f8972d commit e673166
Showing 1 changed file with 60 additions and 24 deletions.
84 changes: 60 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,42 +13,79 @@ This library defines 11 predefined checks and an easy way to implement custom ch
* [License info](#License)

## Checks
There are 11 predfined checks each representing a password criteria.
There are 11 predfined checks each representing a password criteria. Each check type is defined as a bit flag. A combination of checks can thus be simply refrenced using a single integer. All predefined check types are defined [here.](source/EzPasswordValidator/Checks/CheckTypes.cs)

##### Length check
Checks if the given password is equal to or longer than the required minimum length.
#### Length check
Checks if the given password is equal to or longer than the required minimum length
and equal to or shorter than the maximum allowed length.
```
Default minimum length: 8
Default maximum length: 128
```

Changing length bounds example:

```C#
validator.MinLength = 10;
validator.MaxLength = 256;

##### Check for numbers
//OR
validator.SetLengthBounds(10, 256);
```

#### Check for numbers
Checks that the password contains at least one digit.

##### Check for letters
Checks that the password contains at least one letter.
#### Check for letters
Checks that the password contains at least one letter. This check supports multiple alphabets. For more information about how we classify a letter see [this](https://docs.microsoft.com/en-us/dotnet/api/system.char.isletter?view=netframework-4.8#remarks) refrence.

##### Check for symbols
#### Check for symbols
Checks that the password contains at least one symbol.

##### Case check
Checks that the password contains at least one upper- and lower-case letter.
#### Case check
Checks that the password contains at least one upper- and lower-case letter. This check supports multiple alphabets. For more information about how we classify a letter see [this](https://docs.microsoft.com/en-us/dotnet/api/system.char.isletter?view=netframework-4.8#remarks) refrence.

##### Check for number sequences
Checks if the password contains a number series 3 or longer such as 123 or 765.
#### Check for number sequences
Checks if the password contains a number series 3 or longer. Both increasing sequences and decreasing sequences are checked.
```
Example number sequence: 123 | 765
```

##### Check for number repetition
Checks if the password contains number repetition 3 or longer in length, such as 444 or 222.
#### Check for number repetition
Checks if the password contains number repetition 3 or longer in length.
```
Example number repetition: 444 | 222
```

##### Check for number location
Checks that the password does not only have numbers in the front and/or end of the password.
#### Check for number location
Checks that the password does not only have numbers in the front and/or end of the password. To pass this check the password must have a non-digit character before and after a digit character, only one digit must match this pattern.
```
Example invalid password: 2password | password2
Example valid password: 2pass9word | p6ssword
```

##### Check for letter sequences
#### Check for letter sequences
Checks if the password contains an alphabetical letter sequence consisting of four or more
characters. With the exception of the common three letter sequences: abc and xyz.
characters. With the exception of the common three letter sequences: abc and xyz.
Note: this check currently only supports ISO basic latin alphabet (A-Z a-z).
```
Example letter sequence: abc | xyz | bcde
```
##### Check for letter repetition
#### Check for letter repetition
Checks if the password contains letter repetition 3 or longer in length.
The check is not case sensitive meaning 'aAA' and 'aaa' will both match.
This check supports multiple alphabets. For more information about how we classify a letter see [this](https://docs.microsoft.com/en-us/dotnet/api/system.char.isletter?view=netframework-4.8#remarks) refrence.
Note: This check is not case sensitive meaning 'aAA' and 'aaa' will both match.
```
Example letter repetition: aAA | bbb
```

##### Check for symbol repetition
#### Check for symbol repetition
Checks for immediate symbol repetition 3 or longer in sequence.
```
Example symbol repetiton: /// | @@@
```

## Install
There are three main ways to install EzPasswordValidator:
Expand All @@ -64,7 +101,7 @@ Example validator with predefined basic checks.
var validator = new PasswordValidator(CheckTypes.Basic);
```

##### Validate
#### Validate
```C#
bool isValid = validator.Validate(password);
```
Expand All @@ -77,8 +114,7 @@ foreach (Check failedCheck in validator.FailedChecks)
}
```

##### Add checks
All predefined check types are defined [here.](source/EzPasswordValidator/Checks/CheckTypes.cs)
#### Add checks

<i>Add single predefined check</i>
```C#
Expand All @@ -101,7 +137,7 @@ validator.AddCheck("MyCustomCheckTag", psw => psw.Length > 8);
validator.AddCheck(288); //Number sequence check & letter sequence check
```

##### Remove checks
#### Remove checks

```C#
validator.RemoveCheck(CheckTypes.Symbols);
Expand Down

0 comments on commit e673166

Please sign in to comment.