Click here to Skip to main content
15,891,689 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi Everybody,

I have a class Customermodel in which have birthday,birthmonth,birthyear properties.
So i am trying to create a valid date Rules for client side that but i am not able to create it.

I am facing issues at the time of birthday. because it is depend on birthmonth and birthyear.


birthday have multiple validation like:
birthday can not provide null. //working
birthday is alwase between 1-31 or can say can't greater then 31. ///working
birthday is 31 when birthmonth is 1,3...etc. ///not working
birthday is 30 when birthmonth is 4,6...etc. ///not working
birthday must be 28 when birthyear is not leapyear else 29 and month is 2. ///not working

public class Customermodel
{
public int? birtday{get;set;}
public int? birthmonth {get;set;}
public int? birthyear {get;set;}
}

[Validator(typeof(MyViewModelValidator))]
public class CustomerModel {
 public int? BirthYear { get; set; }
 public int? BirthMonth { get; set; }
 public int? BirthDay { get; set; }
}
public class MyViewModelValidator : AbstractValidator<customermodel> {
  public MyViewModelValidator() {
    RuleFor(x => x.BirthDay ).NotNull();    //Here i need the valid date behalf of year and month that will be provided by user. so
}
}


please provide me the solution for that... really thanks
Posted
Updated 4-Jun-13 2:41am
v2
Comments
Sunasara Imdadhusen 4-Jun-13 6:08am    
Where is your code
Sunasara Imdadhusen 4-Jun-13 8:20am    
do not post your code in comment box use update question
Anubhava Dimri 4-Jun-13 8:23am    
If you have the solution then pls provide me else leave it

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900