using System.ComponentModel.DataAnnotations;
using System.Collections.Generic;
public static void Main()
var model = new ViewModel();
var results = new List<ValidationResult>();
if (!Validator.TryValidateObject(model, new ValidationContext(model), results)) {
Console.WriteLine("Model is not valid:");
foreach (var r in results) {
Console.WriteLine(r.ErrorMessage);
Console.WriteLine("Model is valid");
public string PropertyOne { get; set; }
public string PropertyTwo { get; set; }