ID

Uploaded

Status

Description

Work Items

Action

18516
by gflgraham
Nov 22, 2016
3:40 PM

Being evaluated

In regards to patch 18495. The regex for "dateTest2" does not work properly for all dates. I have modified the regex to work for leap years and month day restrictions, ie, January has 31 days, April has only 30, February has 28 or 29 depending on the year etc.

var isDate = function (input) {
var dateTest = new RegExp(/(?=\d)^(?:(?!(?:10\D(?:0?[5-9]|1[0-4])\D(?:1582))|(?:0?9\D(?:0?[3-9]|1[0-3])\D(?:1752)))((?:0?[13578]|1[02])|(?:0?[469]|11)(?!\/31)(?!-31)(?!\.31)|(?:0?2(?=.?(?:(?:29.(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:(?:\d\d)(?:[02468][048]|[13579][26])(?!\x20BC))|(?:00(?:42|3[0369]|2[147]|1[258]|09)\x20BC))))))|(?:0?2(?=.(?:(?:\d\D)|(?:[01]\d)|(?:2[0-8])))))([-.\/])(0?[1-9]|[12]\d|3[01])\2(?!0000)((?=(?:00(?:4[0-5]|[0-3]?\d)\x20BC)|(?:\d{4}(?!\x20BC)))\d{4}(?:\x20BC)?)(?:$|(?=\x20\d)\x20))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2}(?:\x20[aApP][mM]))|(?:[01]\d|2[0-3])(?::[0-5]\d){1,2})?$/);
var dateTest2 = new RegExp("(((19|20)([2468][048]|[13579][26]|0[48])|2000)[\/-]02[\/-]29|((19|20)[0-9]{2}[\/-](0[469]|11)[\/-](0[1-9]|[12][0-9]|30)|(19|20)[0-9]{2}[\/-](0[13578]|1[02])[\/-](0[1-9]|[12][0-9]|3[01])|(19|20)[0-9]{2}[\/-]02[\/-](0[1-9]|1[0-9]|2[0-8])))");

return dateTest.test(input) || dateTest2.test(input);
};

Download

18495
by gflgraham
Nov 17, 2016
9:17 PM

Being evaluated

MvcFoolproofValidation.js
MvcFoolproofJQueryValidation.js
mvcfoolproof.unobtrusive.js

In the above files the function "isDate" does not return the correct result for a date value in the form
yyyy-mm-dd or yyyy/mm/dd. Dates in this format can be obtained, for example, from an input type='date' in chrome.

I dont really want to spend the time messing with the original regex nor do I want to write my own regex for the new date time so I grabbed one off stack overflow that does the job.

The following change to the function now passes all tests.

var isDate = function (input) {
var dateTest = new RegExp(/(?=\d)^(?:(?!(?:10\D(?:0?[5-9]|1[0-4])\D(?:1582))|(?:0?9\D(?:0?[3-9]|1[0-3])\D(?:1752)))((?:0?[13578]|1[02])|(?:0?[469]|11)(?!\/31)(?!-31)(?!\.31)|(?:0?2(?=.?(?:(?:29.(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:(?:\d\d)(?:[02468][048]|[13579][26])(?!\x20BC))|(?:00(?:42|3[0369]|2[147]|1[258]|09)\x20BC))))))|(?:0?2(?=.(?:(?:\d\D)|(?:[01]\d)|(?:2[0-8])))))([-.\/])(0?[1-9]|[12]\d|3[01])\2(?!0000)((?=(?:00(?:4[0-5]|[0-3]?\d)\x20BC)|(?:\d{4}(?!\x20BC)))\d{4}(?:\x20BC)?)(?:$|(?=\x20\d)\x20))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2}(?:\x20[aApP][mM]))|(?:[01]\d|2[0-3])(?::[0-5]\d){1,2})?$/);
var dateTest2 = new RegExp("(((19|20)([2468][048]|[13579][26]|0[48])|2000)[\/-]02[\/-]29|((19|20)[0-9]{2}[\/-](0[4678]|1[02])[\/-](0[1-9]|[12][0-9]|30)|(19|20)[0-9]{2}[\/-](0[1359]|11)[\/-](0[1-9]|[12][0-9]|3[01])|(19|20)[0-9]{2}[\/-]02[\/-](0[1-9]|1[0-9]|2[0-8])))");

return dateTest.test(input) || dateTest2.test(input);
};

Download

12486
by leniel
Jun 25, 2012
9:49 PM

Being evaluated

ContingentValidationAttribute.cs
Added:

public string DependentPropertyDisplayName { get; set; }

Changed:

public override string FormatErrorMessage(string name)
{
if (string.IsNullOrEmpty(ErrorMessageResourceName) && string.IsNullOrEmpty(ErrorMessage))
ErrorMessage = DefaultErrorMessage;

return string.Format(ErrorMessageString, name, DependentPropertyDisplayName ?? DependentProperty);
}

In FoolproofValidator.cs

Changed:

public override IEnumerable<ModelClientValidationRule> GetClientValidationRules()
{
if (Attribute is ContingentValidationAttribute)
{
ContingentValidationAttribute attribute = Attribute as ContingentValidationAttribute;

PropertyInfo otherPropertyInfo = this.Metadata.ContainerType.GetProperty(attribute.DependentProperty);

var displayName = GetAttributeDisplayName(otherPropertyInfo);

attribute.DependentPropertyDisplayName = displayName;
}

var result = new ModelClientValidationRule()
{
ValidationType = Attribute.ClientTypeName.ToLower(),
ErrorMessage = ErrorMessage
};

foreach (var validationParam in Attribute.ClientValidationParameters)
result.ValidationParameters.Add(validationParam);

yield return result;
}

As I'm using EntityFramework with ModelMetadata I had to used these custom functions:

private string GetAttributeDisplayName(PropertyInfo property)
{
var atts = property.GetCustomAttributes(typeof(DisplayAttribute), true);

if (atts.Length == 0)
return null;

return (atts[0] as DisplayAttribute).GetName();
}

Hope it helps,

Leniel

18277

Download

11953
by pavelbalas
Apr 12, 2012
12:37 PM

Being evaluated

When RequiredIfRegExMatch (or RequiredIfNotRegExMatch) attribute is used and dependency property is int, decimal or bool, then client validation doesn’t work correctly. The reason is that foolproof.is function tries to convert both sides (value1 and value2) to dependency property type and fails, because value2 is a regular expression pattern.

Download

11307
by MehCFL
Jan 19, 2012
4:12 PM

Being evaluated

Patch to fix issue with option elements without a value explicitly specified.

17284

Download

11263
by MehCFL
Jan 12, 2012
1:18 PM

Being evaluated

A patch for the Radio buttons true/false issue that works for 'False' as well as 'True'. Sorry about submitting two patches for this.

16416

Download

11262
by MehCFL
Jan 12, 2012
11:47 AM

Being evaluated

A patch for client side validation not working with radio buttons.

16416

Download

10262
by jcruz2us
Aug 24, 2011
3:41 PM

Being evaluated

I've been meaning to submit this patch. The RequireIf validation does not work property with a list of radio buttons. I've replace that code that checks if an item passes the required rule with a call to the required function from the jQuery Validation plugin. I've commented the changes so it should be easy to find them.

16416

Download

7729
by andytsui
Dec 13, 2010
11:25 PM

Being evaluated

This is my attempt to make Foolproof MVC3 unobtrusive script supported.
This include:
1. Change all the client validation parameter names to lower case.
2. Client Jquery Script based to add support to work with the jquery.validate.unobtrusive.js

14871

Download

View All
  • 1-9 of 9 Patches
    • Previous
    • 1
    • Next
    • Showing
    • All
    • Patches