0

I want an input validation for a textbox with capital letters.

For text (or e.g. numbers ...) I use the following way

 public interface IInputValidation
    {
        bool IsValid(string input);
    }

    public class TextValidator : IInputValidation
    {
        public bool IsValid(string input)
        {
            if (input == null || input == "")
            {
                return false;
            }
            else return true;
        }
    }

Can I do a validation in the same way for capital letters? Something like

public class CapitalLetterValidator : IInputValidation
....
Jocelyn
  • 133
  • 1
  • 1
  • 10
  • Asking a yes or no question might not be the best idea. The answer is probably yes. Is there a concrete problem you are facing? – Marco Sep 20 '22 at 08:44
  • 1
    Define what you want to check more precisely. You only want to allow Letters in Uppercase in the input string? – Ralf Sep 20 '22 at 08:44
  • This feels like a front end framework validation. Are you using something like Angular or React? – sr28 Sep 20 '22 at 08:46
  • I don't know how to do the validation for capital letters – Jocelyn Sep 20 '22 at 08:46
  • 1
    Note that your existing IsValid method is the same as `!String.IsNullOrEmpty(input)` – JonasH Sep 20 '22 at 08:50

0 Answers0