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.Models.Attributes { public class OnlyLettersAttribute : ValidationAttribute { public override bool IsValid(object value) { var stringValue = (string)value; foreach (char ch in stringValue) { if (!char.IsLetter(ch)) return false; } return true; } } }