ajv-formats
ajv-formats copied to clipboard
date-time accept timestamp without time zone
According to ajv-formats documentation, "date-time" format specify that time-zone is mandatory. Unfortunately since full validation mode format has been added, it seems that time-zone is not mandatory anymore:
import ajvFormats from "ajv-formats"
const dateWithoutTimeZone = '2022-07-06T13:12:43';
const dateWithTimeZone = '2022-07-06T13:12:43Z';
// validation with new full format mode does not work as expected
console.log(ajvFormats.get("date-time").validate(dateWithoutTimeZone)) // true => should return false
console.log(ajvFormats.get("date-time").validate(dateWithTimeZone)) // true => ok
// validation with fast format mode is ok
console.log(new RegExp(ajvFormats.get("date-time", "fast").validate).test(dateWithoutTimeZone)) // false => ok
console.log(new RegExp(ajvFormats.get("date-time", "fast").validate).test(dateWithTimeZone)) // true => ok
If you confirm the issue, I could propose a pull request.
Same issue for me, but it's fixed in v3.0.0-rc.0