Website Summary Files Commits Branches @commit @diff @stats
path: root / src / DevHive.Web / Attributes / OnlyLettersModelValidation.cs
diff options
context:
space:
mode:
Commit8560caa13b7f7d0e80ee712c77efc59a80e8935c (patch)
Author
 transtrike <transtrike@gmail.com>
2021-01-19 21:46:06 +0200
Committer
 transtrike <transtrike@gmail.com>
2021-01-19 21:46:06 +0200
Files02643afdd46122dfd904fbb8632117a5494081a8 /src/DevHive.Web/Attributes/OnlyLettersModelValidation.cs
DevHive-8560caa13b7f7d0e80ee712c77efc59a80e8935c.tar
DevHive-8560caa13b7f7d0e80ee712c77efc59a80e8935c.tar.gz
DevHive-8560caa13b7f7d0e80ee712c77efc59a80e8935c.zip
Parent661c3194b750e42146e9e28a33da08419b2b2cea (diff)
Added attributes to the Web models for validations
1 files changed, 20 insertions, 0 deletions
-rw-r--r--src/DevHive.Web/Attributes/OnlyLettersModelValidation.cs20
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;
+ }
+ }
+}