Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Core: Add sanity checks to dateISO #1528

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 57 commits into from
Closed

Core: Add sanity checks to dateISO #1528

wants to merge 57 commits into from

Conversation

RobJohnston
Copy link
Contributor

Added checks for leap years and for months that only have 30 days.

I've re-used the regex for dateISO, but I was talking to @nschonni and from what we can see, the slashes are not part of the ISO 8601 standard (but the canonical source is paywalled). It's either a dash or nothing, so maybe the regex should be /^(\d{4})(?:\-)*(0?[1-9]|1[012])(?:\-)*(0?[1-9]|[12][0-9]|3[01])$/.

@RobJohnston
Copy link
Contributor Author

Relates to #939 and #1000.

src/core.js Outdated
}
}
}
return this.optional(element) || check;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move the optional check in a short-circuit to be consistent with other rules which do the heavy checks only when necessary

@RobJohnston
Copy link
Contributor Author

@staabm : Like so? I was being consistent with dateITA originally.

@jzaefferer
Copy link
Collaborator

Thanks for the contribution! While we're at it, let's drop the slashes and update the tests accordingly. I have no idea why they're there. W3C doesn't list anything with slashes either: http://www.w3.org/TR/NOTE-datetime

@RobJohnston
Copy link
Contributor Author

Just drop the slashes or also allow YYYYMMDD in addition to YYYY-MM-DD?

@jzaefferer
Copy link
Collaborator

Just disallow slashes, only allows dashes as separator.

@Arkni
Copy link
Member

Arkni commented Jul 22, 2015

Does that make sense if this validator accepts years between 0000 and 9999 ?
because MySQL 5.x accept dates between 1000-01-01 and 9999-12-31.

@RobJohnston
Copy link
Contributor Author

True for MySQL, but different databases have different ranges (and sometimes dates are not stored in databases):

A quick search:

I would think that the min method and max method would be the places to specify acceptable ranges.

EDIT: Maybe not. This came up in #455 and could not be easily fixed.

@staabm
Copy link
Member

staabm commented Oct 21, 2015

Not sure we can handle as invalid which were valid before and vice versa. I would merge such a change only with a new major version

@RobJohnston
Copy link
Contributor Author

But was February 31st ever really valid?

@staabm staabm added this to the 2.0.0 milestone Oct 21, 2015
@staabm
Copy link
Member

staabm commented Nov 24, 2015

at least 1990/06/06, 1990-6-6 and 1990/6/6 were valid before..

Arkni and others added 23 commits March 6, 2016 12:18
I found no appearant reason why a BIC has to be all-upper,
so allowing customers to enter it lowercase or mixed should be ok.
Furthermore, the IBAN-validation also is case-insensitive.

Closes #1547
For historical reasons, the value IDL attribute prefixes the file name
with the string "C:\fakepath\". As a result of this,
this fix will extract the file name from the value IDL attribute in a
backwards-compatible way.

For more details, see:
 - http://www.w3.org/TR/html5/forms.html#dom-input-value-filename
 - http://www.w3.org/TR/html5/forms.html#fakepath-srsly

Fixes #1615
`^0.4.0` Is equivalent to `0.4.*` but actually for a sementic versioned lib what we want is `>=0.4` aka `^0.4`
Closes #1673.

Hello, and thank you for this good plugin
I find a bug in Farsi (Persian) localization exist in messages_fa.js
The "min"&"max" methods messages in that file have bug. The Farsi "min"
`s message has this meaning: “please enter value greater that {0}
words.”
Phrase meaning "word" should be removed from Farsi message.
…tion

Conflicts:
	src/additional/accept.js
	src/additional/additional.js
	src/additional/bankaccountNL.js
	src/additional/bic.js
	src/additional/cpfBR.js
	src/additional/creditcardtypes.js
	src/additional/dateITA.js
	src/additional/iban.js
	src/additional/phonesUK.js
	src/additional/url2.js
	src/core.js
	src/localization/messages_pt_BR.js
	test/error-placement.js
	test/index.html
	test/methods.js
@staabm staabm force-pushed the master branch 2 times, most recently from d621aab to 3861ce2 Compare September 26, 2016 14:28
RobJohnston added a commit to RobJohnston/jquery-validation that referenced this pull request Jul 14, 2017
Redo of PR due to mangled repo. Still fixes jquery-validation#1528.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.