Lost ability to use "date-time" format in JSON Scheme (version 7.0.0)
lnovelli opened this issue · 3 comments
HI,
I just upgraded to 7.0.0, but I get the following error when loading the store using a JSON scheme:
Error: unknown format "date-time" ignored in schema at path "#/properties/extra/properties/lastStartDate"
Nothing else has changed, just the packages upgrade. Am i missing something? 🤔
My JSON Scheme is the following:
type AppDatabaseExtra = { lastStartDate: Date }
type AppDatabaseModel = {
extra: AppDatabaseExtra;
}
const AppDatabaseSchema: Schema<AppDatabaseModel> = {
extra: {
type: 'object',
properties: {
lastStartDate: {
type: "string",
format: "date-time"
}
}
}
}
And I initialize it like this:
this.store = new Store<AppDatabaseModel>({
name: "appDatabase",
schema: AppDatabaseSchema,
clearInvalidConfig: true
});
Thank you
Please read the release notes.
@sindresorhus Could you clarify if it's still supposed to be possible to use ajv
formats as stated in the README? I've read the release notes (the part about ajv
being updated to v7), but as far as I can tell it's currently impossible to use formats, which explains this issue.
In order to add formats to ajv
v7, you need access to the Ajv
instance, which conf
does not seem to expose:
import Ajv from "ajv"
import addFormats from "ajv-formats"
const ajv = new Ajv()
addFormats(ajv)
I missed that in Ajv release notes.
I think we can just depend on ajv-formats
in conf
since that's how it used to work. PR welcome.