I Have to validate the max length of an int or long with FluentValidation
I want to use something like this
int PortCode = 4444;
RuleFor(x => x.PortCode).NotEmpty().MaximumLength(10);
but FluentValidation does not support it
what is the solution;
2
Answers
please use this custom validation
using FluentValidation;
you don’t need custom validation
you can do this instead
RuleFor(a => a.PortCode).NotEmpty().Must(w => w.ToString().Length < 10);