Tuple of date-time does not allow Date
qwelias opened this issue · 3 comments
qwelias commented
Prerequisites
- I have written a descriptive issue title
- I have searched existing issues to ensure the bug has not already been reported
Fastify version
latest
Plugin version
No response
Node.js version
20
Operating system
Linux
Operating system version (i.e. 20.04, 11.3, 10)
Arch
Description
Throws on stringifying Date
for schema with {type: 'string',format: 'date-time'}
Steps to Reproduce
require('./index.js')({
title: 'dates tuple',
type: 'object',
properties: {
dates: {
type: 'array',
minItems: 2,
maxItems: 2,
items: [
{
type: 'string',
format: 'date-time'
},
{
type: 'string',
format: 'date-time'
}
]
}
}
})({
dates: [new Date(1), new Date(2)]
}) // Error: Item at 0 does not match schema definition.
Expected Behavior
Does not throw on stringifying Date
for schema with {type: 'string',format: 'date-time'}
qwelias commented
I've tried to put together a PR for fixing it, but am not sure if need to check for format
before allowing Date
and if it's ok to just add || instanceof Date
in buildArrayTypeCondition
's string
case (and || instanceof RegExp
as in buildMultiTypeSerializer
?)
qwelias commented
@mcollina hi, I'm willing to contribute here, just need a bit if advice regarding my previous comment when you have time
ivan-tymoshenko commented