I have a Save method which gets a view model passed in. In the Viewmodel I have a bunch of custom validations that happen.
public class DealViewModel : IValidatableObject
{
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
}
}
public IActionResult SaveDeal(DealViewModel dealViewModel)
{
}
I want to run the validation after it hits the save method as I need to get information from session update the view model and then validate.
This is how I validate:
var isValid = Validator.TryValidateObject(dealViewModel, context, results, true);
But my code hits the validation method before it even its in the SaveDeal method in the controller.
Is there a way to stop that and just force validate when I am ready?