aboutsummaryrefslogtreecommitdiff
path: root/src/Web/DevHive.Web/Attributes
diff options
context:
space:
mode:
authortranstrike <transtrike@gmail.com>2021-02-13 16:20:18 +0200
committertranstrike <transtrike@gmail.com>2021-02-13 16:20:18 +0200
commit98e17766b203734a1817eed94338e2d25f4395f7 (patch)
tree1266385a56cba56fd55c7faf661dd844bbdf5705 /src/Web/DevHive.Web/Attributes
parent1ab34accfda22ee3ce5c7700e3b97ff3e932d649 (diff)
downloadDevHive-98e17766b203734a1817eed94338e2d25f4395f7.tar
DevHive-98e17766b203734a1817eed94338e2d25f4395f7.tar.gz
DevHive-98e17766b203734a1817eed94338e2d25f4395f7.zip
Project Restructure P.1
Diffstat (limited to 'src/Web/DevHive.Web/Attributes')
-rw-r--r--src/Web/DevHive.Web/Attributes/GoodPasswordModelValidation.cs24
-rw-r--r--src/Web/DevHive.Web/Attributes/OnlyLettersModelValidation.cs20
2 files changed, 44 insertions, 0 deletions
diff --git a/src/Web/DevHive.Web/Attributes/GoodPasswordModelValidation.cs b/src/Web/DevHive.Web/Attributes/GoodPasswordModelValidation.cs
new file mode 100644
index 0000000..7d6a1ea
--- /dev/null
+++ b/src/Web/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/Web/DevHive.Web/Attributes/OnlyLettersModelValidation.cs b/src/Web/DevHive.Web/Attributes/OnlyLettersModelValidation.cs
new file mode 100644
index 0000000..07afee9
--- /dev/null
+++ b/src/Web/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;
+ }
+ }
+}