Skip to content
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

isDate(): Format 'DD.MM.YYYY' does not pass isValidFormat #1709

Closed
flymans opened this issue Aug 19, 2021 · 3 comments · Fixed by #1711
Closed

isDate(): Format 'DD.MM.YYYY' does not pass isValidFormat #1709

flymans opened this issue Aug 19, 2021 · 3 comments · Fixed by #1711
Labels

Comments

@flymans
Copy link
Contributor

flymans commented Aug 19, 2021

Describe the bug

I can't set DD.MM.YYYY format, because function isValidFormat returns false.
I can't go with workaround like isDate("19.08.2021", { format: 'DD/MM/YYYY', delimiters: ["/", "."] }); because it approves dates with "/" delimeter

Examples
isDate("19/08/2021", { format: 'DD.MM.YYYY', delimiters: ["."], strictMode: true }); returns false

Additional context
Validator.js version: 13.6.1
Node.js version: 12.15.0
OS platform: [linux]

@flymans
Copy link
Contributor Author

flymans commented Aug 19, 2021

Is it possible to edit current function:
function isValidFormat(format) { return /(^(y{4}|y{2})[\/-](m{1,2})[\/-](d{1,2})$)|(^(m{1,2})[\/-](d{1,2})[\/-]((y{4}|y{2})$))|(^(d{1,2})[\/-](m{1,2})[\/-]((y{4}|y{2})$))/gi.test(format); }

to this:
function isValidFormat(format) { return /(^(y{4}|y{2})[.\/-](m{1,2})[.\/-](d{1,2})$)|(^(m{1,2})[.\/-](d{1,2})[.\/-]((y{4}|y{2})$))|(^(d{1,2})[.\/-](m{1,2})[.\/-]((y{4}|y{2})$))/gi.test(format); }

(added only "." in every character set [.\/-])

@flymans
Copy link
Contributor Author

flymans commented Sep 21, 2021

I fixed it myself, PR is waiting for review a month already.

@tux-tn
Copy link
Member

tux-tn commented Sep 22, 2021

@flymans sorry for the long delay🙏 I will review your PR today

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants