-
Notifications
You must be signed in to change notification settings - Fork 640
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
type must be JSONType or JSONType[]: date-time #2142
Comments
Valid types are JSON types |
Here's the JSON schema spec https://json-schema.org/specification.html |
Thank you, I see now 😄 |
Is there any way how to use/import |
Ok my fault RTFM 😄 |
how can i use it in model like this please @thefoxie static get jsonSchema() { |
@WafaBoussada you have to change it somewhere where you init objectionjs. In my case: import knex from "knex";
import Objection from "objection";
import addFormats from "ajv-formats";
import config from "./config.js";
const { Model: ObjectionModel, AjvValidator } = Objection;
class Model extends ObjectionModel {
static createValidator() {
return new AjvValidator({
onCreateAjv: (ajv) => {
addFormats(ajv);
},
/* options: {
allErrors: true,
validateSchema: false,
ownProperties: true,
v5: true,
}, */
});
}
}
const knexInit = knex(config[process.env.NODE_ENV || "development"]);
Model.knex(knexInit);
export default Model; |
@thefoxie in my case i did this i create file validate model with this code class ValidatedModel extends Model { module.exports = ValidatedModel and then i do this in the model cart static get jsonSchema() { but it didin't work the same error always type must be JSONType or JSONType[]: date |
@WafaBoussada see https://ajv.js.org/guide/formats.html |
@thefoxie i got this error unknown format "date-time" ignored in schema at path "#/properties/modification_date" |
@WafaBoussada might be somewhere else (in different model). |
@thefoxie i will see thxx |
@thefoxie hello for the type timestamp when i put { type: "string", format: "timestamp" } it make an error. i think timestamp format not used in ajv-formats. there is a solution fo this ? |
@WafaBoussada |
For anyone wondering, if you go down the route of adding the ajv-formats package and creating a property with Wasn't obvious to me so thought I'd add a note. |
After update to the 3.0.0 I got this validation error.
The text was updated successfully, but these errors were encountered: