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

Joi.date().iso() throws error when required() is used. #503

Closed
fampinheiro opened this Issue Dec 1, 2014 · 0 comments

Comments

Projects
None yet
2 participants
@fampinheiro
Copy link
Contributor

fampinheiro commented Dec 1, 2014

The following code:

var Joi = require('joi');
Joi.validate('2014-12-02T11:00:20.000Z', Joi.date().iso().required());

throws:

/Users/fampinheiro/Workspace/projects/t-joi/node_modules/joi/node_modules/moment/moment.js:1060
            format = format.replace(localFormattingTokens, replaceLongDateForm
                            ^
TypeError: Object /^((\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\d))$/ has no method 'replace'
    at expandFormat (/Users/fampinheiro/Workspace/projects/t-joi/node_modules/joi/node_modules/moment/moment.js:1060:29)
    at makeDateFromStringAndFormat (/Users/fampinheiro/Workspace/projects/t-joi/node_modules/joi/node_modules/moment/moment.js:1474:18)
    at makeMoment (/Users/fampinheiro/Workspace/projects/t-joi/node_modules/joi/node_modules/moment/moment.js:1798:17)
    at moment (/Users/fampinheiro/Workspace/projects/t-joi/node_modules/joi/node_modules/moment/moment.js:1832:16)
    at Object.internals.toDate (/Users/fampinheiro/Workspace/projects/t-joi/node_modules/joi/lib/date.js:63:24)
    at internals.Date._base (/Users/fampinheiro/Workspace/projects/t-joi/node_modules/joi/lib/date.js:28:46)
    at internals.Any._validate (/Users/fampinheiro/Workspace/projects/t-joi/node_modules/joi/lib/any.js:371:31)
    at internals.Any._validateWithOptions (/Users/fampinheiro/Workspace/projects/t-joi/node_modules/joi/lib/any.js:425:23)
    at root.validate (/Users/fampinheiro/Workspace/projects/t-joi/node_modules/joi/lib/index.js:102:23)
    at Object.<anonymous> (/Users/fampinheiro/Workspace/projects/t-joi/index.js:2:5)

@Marsup Marsup added the bug label Dec 1, 2014

@Marsup Marsup self-assigned this Dec 1, 2014

@Marsup Marsup added this to the 5.0.2 milestone Dec 1, 2014

@Marsup Marsup closed this in #505 Dec 1, 2014

Marsup added a commit that referenced this issue Dec 1, 2014

Merge pull request #505 from fampinheiro/master
Convert date regex to date before comparison. Closes #503.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.