/// <summary> /// A validation function that checks if the value is a DateTime and reports a validation error if not. /// </summary> /// <param name="dp">Data property being validated.</param> /// <param name="value">The value to validate.</param> /// <param name="row">The row in a list object or null for regular data objects.</param> public static void ValidateDateTime(DataProperty dp, object value, DataRow row) { DateTimeProperty dtp = dp as DateTimeProperty; if (dp != null && !dp.IsValueNull(value, ValueFormat.Internal) && !(value is DateTime)) { dp.AddValidationError(row, Messages.Validation_DateTimeFormat, dp, value, dtp != null ? dtp.Format : "N/A"); } }
/// <summary> /// A validation function that checks if the value is a DateTime and reports a validation error if not. /// </summary> /// <param name="dp">Data property being validated.</param> /// <param name="value">The value to validate.</param> public static void ValidateDateTime(DataProperty dp, object value) { DateTimeProperty dtp = dp as DateTimeProperty; if (dp != null && !dp.IsValueNull(value, ValueFormat.Internal) && !(value is DateTime)) { dp.ValidationErrors.AddValidationError("{0} has an invalid date/time: {1}. Please use the following format: {2}.", dp, value, dtp != null ? dtp.Format : "N/A"); } }