aboutsummaryrefslogtreecommitdiff
path: root/src/DevHive.Web/Attributes/OnlyLettersModelValidation.cs
blob: 07afee967dada6766aa7aa953476313402142f6d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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;
		}
	}
}