Treefrog.Windows.Controllers.ValidationController.ValidateNonEmptyName C# (CSharp) Method

ValidateNonEmptyName() public static method

public static ValidateNonEmptyName ( string fieldName, TextBox control, IEnumerable reservedNames ) : Func
fieldName string
control System.Windows.Forms.TextBox
reservedNames IEnumerable
return Func
        public static Func<string> ValidateNonEmptyName(string fieldName, TextBox control, IEnumerable<string> reservedNames)
        {
            return () => {
                string txt = (control.Text ?? "").Trim();

                if (string.IsNullOrWhiteSpace(txt))
                    return fieldName + " must not be empty";
                if (reservedNames != null && reservedNames.Contains(txt))
                    return fieldName + " conflicts with another name";
                return null;
            };
        }