aboutsummaryrefslogtreecommitdiff
path: root/src/Web/DevHive.Web.Models/Attributes/GoodPasswordModelValidation.cs
diff options
context:
space:
mode:
authortranstrike <transtrike@gmail.com>2021-02-13 18:16:37 +0200
committertranstrike <transtrike@gmail.com>2021-02-13 18:16:37 +0200
commitad3b8e0070c0abdf0b87bd50428e509e1bff2d8e (patch)
tree0da2c6aa256e00ff6ee3fec55ba4aaa95abba0e5 /src/Web/DevHive.Web.Models/Attributes/GoodPasswordModelValidation.cs
parentc5b27c7eb62cc5428a0c01ffcf381f429d776122 (diff)
downloadDevHive-ad3b8e0070c0abdf0b87bd50428e509e1bff2d8e.tar
DevHive-ad3b8e0070c0abdf0b87bd50428e509e1bff2d8e.tar.gz
DevHive-ad3b8e0070c0abdf0b87bd50428e509e1bff2d8e.zip
Restructure Successful
Diffstat (limited to 'src/Web/DevHive.Web.Models/Attributes/GoodPasswordModelValidation.cs')
-rw-r--r--src/Web/DevHive.Web.Models/Attributes/GoodPasswordModelValidation.cs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/Web/DevHive.Web.Models/Attributes/GoodPasswordModelValidation.cs b/src/Web/DevHive.Web.Models/Attributes/GoodPasswordModelValidation.cs
new file mode 100644
index 0000000..5ecb41a
--- /dev/null
+++ b/src/Web/DevHive.Web.Models/Attributes/GoodPasswordModelValidation.cs
@@ -0,0 +1,24 @@
+using System;
+using System.ComponentModel.DataAnnotations;
+
+namespace DevHive.Web.Models.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;
+ }
+ }
+}