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;
};
}