diff options
| author | Victor S <57849063+transtrike@users.noreply.github.com> | 2021-02-05 10:54:49 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-05 10:54:49 -0800 |
| commit | f4a70c6430db923af9fa9958a11c2d6612cb52cc (patch) | |
| tree | ca0ea403ba5500df20bc8854ec50529a25c64245 /src/DevHive.Web/Attributes | |
| parent | 1ccdefdac025b1b986ad2bd0bc3eda7505d6e7c3 (diff) | |
| parent | 2269b5aa6c8d3dcb407c34fa256200bdc573585a (diff) | |
| download | DevHive-f4a70c6430db923af9fa9958a11c2d6612cb52cc.tar DevHive-f4a70c6430db923af9fa9958a11c2d6612cb52cc.tar.gz DevHive-f4a70c6430db923af9fa9958a11c2d6612cb52cc.zip | |
Merge pull request #18 from Team-Kaleidoscope/devv0.1
First stage: Complete. Awaiting further progress...
Diffstat (limited to 'src/DevHive.Web/Attributes')
| -rw-r--r-- | src/DevHive.Web/Attributes/GoodPasswordModelValidation.cs | 24 | ||||
| -rw-r--r-- | src/DevHive.Web/Attributes/OnlyLettersModelValidation.cs | 20 |
2 files changed, 44 insertions, 0 deletions
diff --git a/src/DevHive.Web/Attributes/GoodPasswordModelValidation.cs b/src/DevHive.Web/Attributes/GoodPasswordModelValidation.cs new file mode 100644 index 0000000..7d6a1ea --- /dev/null +++ b/src/DevHive.Web/Attributes/GoodPasswordModelValidation.cs @@ -0,0 +1,24 @@ +using System; +using System.ComponentModel.DataAnnotations; + +namespace DevHive.Web.Attributes +{ + public class GoodPassword : ValidationAttribute + { + public override bool IsValid(object value) + { + var stringValue = (string)value; + + for (int i = 0; i < stringValue.Length; i++) + { + if (Char.IsDigit(stringValue[i])) + { + base.ErrorMessage = "Password must be atleast 5 characters long!"; + return stringValue.Length >= 5; + } + } + base.ErrorMessage = "Password must contain atleast 1 digit!"; + return false; + } + } +} diff --git a/src/DevHive.Web/Attributes/OnlyLettersModelValidation.cs b/src/DevHive.Web/Attributes/OnlyLettersModelValidation.cs new file mode 100644 index 0000000..07afee9 --- /dev/null +++ b/src/DevHive.Web/Attributes/OnlyLettersModelValidation.cs @@ -0,0 +1,20 @@ +using System; +using System.ComponentModel.DataAnnotations; + +namespace DevHive.Web.Attributes +{ + public class OnlyLetters : ValidationAttribute + { + public override bool IsValid(object value) + { + var stringValue = (string)value; + + foreach (char ch in stringValue) + { + if (!Char.IsLetter(ch)) + return false; + } + return true; + } + } +} |
