using System;
using System.Linq;
using System.ComponentModel.DataAnnotations;

namespace CarErrorSample.ViewModels
{
    public class Car:IValidatableObject
    {
        [ScaffoldColumn(false)]
        public int Id { get; set; }
        [Required]
        public string Name { get; set; }
        [Required]
        public string Model { get; set; }
        [Range(300,1500),UIHint("Number")]
        public double Weight { get; set; }
        [CustomValidator,UIHint("CarType")]
        public string Type { get; set; }
        [Required,UIHint("Country")]
        public string Country { get; set; }

        public System.Collections.Generic.IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        {
            // here i am trying to validate Country not using the custom validator
            if (Country == "N/A")
                yield return new ValidationResult("Country filed is required!");
        }
    }
}