Advertisement
Krasipeace

Generic Validate

Apr 2nd, 2023
481
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.25 KB | None | 0 0
  1. private static bool IsValid(object dto)
  2. {
  3.     var validationContext = new ValidationContext(dto);
  4.     var validationResult = new List<ValidationResult>();
  5.  
  6.     return Validator.TryValidateObject(dto, validationContext, validationResult, true);
  7. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement