/// <summary> /// Method to check the lenght of the title /// </summary> /// <param name="Title">Title of the post</param> /// <param name="error">Will error if lenght is greater than annotation</param> /// <returns>Returns false if there is an error</returns> public static bool ValidateTitle(string Title, out string error) { lock (_locker) { error = ""; bool result = true; if (Title.Length > DataAnnotation.GetMaxLengthFromStringLengthAttribute(typeof(Posts), "title")) { error = "Title is too long"; result = false; } return(result); } }
/// <summary> /// Checks the leght of the author /// </summary> /// <param name="Author">checks again the annotation in the Post class</param> /// <param name="error">returns false if its greater than annotation</param> /// <returns>returns false if its greater than annotation</returns> public static bool ValidateAuthor(string Author, out string error) { lock (_locker) { bool result = true; error = ""; if (Author.Length > DataAnnotation.GetMaxLengthFromStringLengthAttribute(typeof(Posts), "author")) { error = "Author is too long"; } return(result); } }