Skip to content

Instantly share code, notes, and snippets.

@brainded
Last active December 15, 2015 01:39
Show Gist options
  • Save brainded/5182061 to your computer and use it in GitHub Desktop.
Save brainded/5182061 to your computer and use it in GitHub Desktop.
Run Validator Manually on DataAnnotations. Useful when using DataAnnotations in a Non MVC Context, like a console application or a service.
var objectToValidate = new ObjectToValidate();
var context = new ValidationContext(goUpgradesStandbyProductRequestData, null, null);
var results = new List<ValidationResult>();
bool isValid = Validator.TryValidateObject(objectToValidate, context, results, true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment