Validation for Model Object using Fluent Validation I am using fluentvalidation to validate my object model. I have to make sure that the first two characters of an ISIN must be letters / non numeric. The way I did it is to convert the string to a char array and then perform regex on the first two characters. I was wondering if anyone has a nicer way of doing the validation using a custom fluent validation. Thanks
    public class Create
    {
        public class Command : IRequest
        {
            public string Name { get; set; }

            public string Exchange { get; set; }

            public string Ticker { get; set; }

            public string Isin { get; set; }

            public string Website { get; set; }
        }

        public class CommandValidator : AbstractValidator&lt;Command&gt;
        {
            public CommandValidator()
            {
                RuleFor(x =&gt; x.Name).NotEmpty();
                RuleFor(x =&gt; x.Isin).SetValidator(new MyValidator());
            }
        }

        public class MyValidator : PropertyValidator
        {
            public MyValidator(
                string errorMessage = &quot;Isin. The first two characters of an ISIN must be letters / non numeric.&quot;) : base(errorMessage)
            {
            }

            protected override bool IsValid(PropertyValidatorContext context)
            {
                var stringToValidate = context.PropertyValue as String;
                return IsValid(stringToValidate);
            }

            public bool IsValid(string stringToValidate)
            {
                var charString = stringToValidate.ToCharArray();
                if (Regex.IsMatch(charString[0].ToString(), &quot;[0-9]&quot;) || Regex.IsMatch(charString[1].ToString(), &quot;[0-9]&quot;))
                {
                    return false;
                }

                return true;
            }

            public class Handler : IRequestHandler&lt;Command&gt;
            {
                private readonly DataContext _context;

                public Handler(DataContext context)
                {
                    _context = context;
                }
                public async Task&lt;Unit&gt; Handle(Command request,
                    CancellationToken cancellationToken)
                {
                    var company = new Company
                    {
                        Name = request.Name,
                        Exchange = request.Exchange,
                        Ticker = request.Ticker,
                        Isin = request.Isin,
                        Website = request.Website
                    };

                    await _context.Companies.AddAsync(company);

                    var success = await _context.SaveChangesAsync() &gt; 0;

                    if (success) return Unit.Value;

                    throw new Exception(&quot;Problem saving changes&quot;);
                }
            }
        }
    }
}
public bool IsValid(string stringToValidate)
{
    var charString = stringToValidate.ToCharArray();
    if (Regex.IsMatch(charString[0].ToString(), &quot;[0-9]&quot;) || Regex.IsMatch(charString[1].ToString(), &quot;[0-9]&quot;))
    {
        return false;
    }
    return true;
}


Be aware that each char in a string can be reached by index as stringToValidate[0], so you don't need to call ToCharArray():
public bool IsValid(string stringToValidate)
{        
    if (Regex.IsMatch(stringToValidate[0].ToString(), &quot;[0-9]&quot;) || Regex.IsMatch(stringToValidate[1].ToString(), &quot;[0-9]&quot;))
    {
        return false;
    }
    return true;
}

But Char has a static method Char.IsLetter() that can be used instead of the Regex expression:
public bool IsValid(string stringToValidate)
{
     return stringToValidate.Length &gt; 1 &amp;&amp; Char.IsLetter(stringToValidate[0]) &amp;&amp; Char.IsLetter(stringToValidate[1]);
}

This is more consistent with modern unicode character sets, and it will also catch if the two first characters are special chars like '&amp;' or '!' etc. If you just want to ensure they are not numeric, you can use Char.IsDigit() instead.