Skip to content

isoDate doesn't recognize correct string #2419

@mzl-md

Description

@mzl-md

Support plan

  • is this issue currently blocking your project? (yes/no): no
  • is this issue affecting a production system? (yes/no): yes

Context

  • node version: v14.5.0
  • module version with issue: 17.1.1
  • last module version without issue: Unknown
  • environment (e.g. node, browser, native): node
  • used with (e.g. hapi application, another framework, standalone, ...): aws-sdk
  • any other relevant information:

What are you trying to achieve or the steps to reproduce?

I'm validating an ISO string as seen in productive environment: 2019-01-22T07:16:46+01. While the regex from lib/common.js works fine, I still get a validation error when using isoDate().

// this fails:
console.log(Joi.string().isoDate().validate("2019-01-22T07:16:46+01"));
// but this works:
console.log(Joi.string().isoDate().validate("2019-01-22T07:16:46+01:00"));

What was the result you got?

{
  value: '2019-01-22T07:16:46+01',
  error: [Error [ValidationError]: "value" must be in iso format] {
    _original: '2019-01-22T07:16:46+01',
    details: [ [Object] ]
  }
}

What result did you expect?

{ value: '2019-01-22T06:16:46.000Z' }

Metadata

Metadata

Assignees

Labels

bugBug or defect

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions