I have a class called Transaction
which contains a property named source
Within the Transaction
class I have some validation using FluentValidation
, I am currently trying to validate the source property using regex
however I'm having an issue
//source isnt required but when present must be 1 character 'X' or 'Y'
RuleFor(transaction => transacion.source)
.Matches("^(X|Y)?$")
.When(Transaction => transaction.source != null);
I am getting:
Error 1
FluentValidation.IRuleBuilderInitial<MyUtility.Transaction,char?>
does not contain a definition for 'Matches' and the best extension method overloadFluentValidation.DefaultValidatorExtensions.Matches<T>(FluentValidation.IRuleBuilder<T,string>, System.Text.RegularExpressions.Regex)
has some invalid arguments
I have just used this exact same code for a different property with no problems, although that was a string not a char.