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 · Fixed by #505
Closed

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

fampinheiro opened this issue Dec 1, 2014 · 0 comments · Fixed by #505
Labels
bug Bug or defect
Milestone

Comments

@fampinheiro
Copy link
Contributor

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 Bug or defect 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 added a commit that referenced this issue Dec 1, 2014
Convert date regex to date before comparison. Closes #503.
@lock lock bot locked as resolved and limited conversation to collaborators Jan 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Bug or defect
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants