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

Date-time with no timezone is considered valid #54

Closed
bernardodesousa opened this issue Mar 2, 2022 · 1 comment
Closed

Date-time with no timezone is considered valid #54

bernardodesousa opened this issue Mar 2, 2022 · 1 comment
Labels
duplicate This issue or pull request already exists

Comments

@bernardodesousa
Copy link

bernardodesousa commented Mar 2, 2022

I'm using Ajv 8.10.0, latest version as of this writing.

const Ajv = require("ajv")
const addFormats = require('ajv-formats')
const ajv = new Ajv()

addFormats(ajv)

const validate = ajv.compile({
    type: "string",
    format: "date-time"
})

console.log(validate('2018-01-26T00:18:49.000')) // true

An RFC3339 date time string with no timezone is valid, but since Ajv website says the time-zone is mandatory for the "date-time" format, I expected the code above to raise an error. It outputs true.

What am I missing? Is it expected behavior? If so, maybe the website should be updated.

@epoberezkin epoberezkin transferred this issue from ajv-validator/ajv Mar 5, 2022
@epoberezkin
Copy link
Member

It’s resolved in https://github.com/ajv-validator/ajv-formats/releases/tag/v3.0.0-rc.0

in 2.x date-time as validated as iso where time zone is optional

@epoberezkin epoberezkin added duplicate This issue or pull request already exists and removed bug report labels Mar 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Development

No branches or pull requests

2 participants