MvcValidatorToolkit/Validators/ValidateDate.cs
/// <summary>
/// Validates the given element using the Values collection and generates an error if 
/// invalid.
/// </summary>
Validates the given element using the Values collection and generates an error if
invalid.
Validates the given element using the Values collection and generates an error if invalid .
protected override void Validate(string element)
		{
			bool isValid = false;
			if(Values.ContainsKey(element))
			{
				string[] dateFormats = GetDateFormatArray();
				DateTime date;
				if(DateTime.TryParseExact(Values[element], dateFormats, CultureInfo.InvariantCulture, DateTimeStyles.None, out date))
					isValid = true;
			}
			if(isValid == false)
				InsertError(element);
		}
protected override void Validate ( string element ) { bool isValid = false ; if ( Values . ContainsKey ( element ) ) { string [ ] dateFormats = GetDateFormatArray ( ) ; DateTime date ; if ( DateTime . TryParseExact ( Values [ element ] , dateFormats , CultureInfo . InvariantCulture , DateTimeStyles . None , out date ) ) isValid = true ; } if ( isValid == false ) InsertError ( element ) ; }
Validates the given element using the Values collection and generates an error if
invalid.
Validates the given element using the Values collection and generates an error if invalid .
element
string