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

namespace CarErrorSample.ViewModels
{
    public class CustomValidator : ValidationAttribute
    {
        public override bool IsValid(object value)
        {
            if (value.GetType() == typeof(string))
                if (value.ToString() == "N/A")
                {
                    ErrorMessage = "Type is required";
                    return false;
                }
                else
                    return true;
            else
                return base.IsValid(value);
        }
    }
}