Skip to content

Instantly share code, notes, and snippets.

View JustinMason's full-sized avatar

Justin Mason JustinMason

  • MongoDB
  • Denver, CO
View GitHub Profile
public class HomePageViewModel
{
[Display(Order=0, Name="Full Name")]
[Required(ErrorMessage="Full Name is Required")]
public string Name { get; set; }
[Display(Order=1, Name="Birthday") ]
[DateComparer(MaxDateAddDaysFromNow=0, MinDateSelector="PropertyDate")]
//Must be less than Now and Greater than the sibling property PropertyDate
public DateTime BirthDate { get; set; }
(function ($) {
// The adapter to support ASP.NET MVC unobtrusive validation
$.validator.unobtrusive.adapters.add('rangedate', ['minselector', 'maxselector', 'mindate', 'maxdate', 'nullable'],
function(options) {
var params = {
minSelector: options.params.minselector,
maxSelector: options.params.maxselector,
minDate: options.params.mindate,
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
public class DateComparerAttribute : ValidationAttribute, IClientValidatable
{
/// <summary>
/// If set will use DateTime.AddDays to specify the Min Valid Date
/// </summary>
public double MinDateAddDaysFromNow
{
get { return _minDateAddDaysFromNow; }
set
[ServiceContract]
public interface ICustomerService
{
[OperationContract]
Customer GetCustomer(int id);
[OperationContract]
void SaveCustomer(ref Customer customer);
}