C
C#3y ago
Anton

FluentValidation for particular values in absence of the whole data model object

Say, I wanted to validate if FirstNane satisfied a regex prior to model creation. So I'd like to be able to say FirstNameValidator.Validate(str) to check if it would be valid on a model object, and get the errors, but not creating the model object first, setting all fields correctly, and then running the validator, or having another ModelFirstNameValidator which still needs a whole model to validate a single thing. You can assume the validity of first name is independent of the state of the whole object. How do I define a validator for just a particular type, and then aggregate it in the validator for the whole model? Does it make sense?
1 Reply
Anton
AntonOP3y ago
So what should I be doing for testing individual fields in absence of the data model?

Did you find this page helpful?