Closed ozum closed 6 years ago
Hi,
If name property is not present in schema, field name in thrown error (by Joi) is undefined.
name
undefined
It may not be a bug (name property is already missing), but during conversion Enjoi may use property key as field name if it is not present.
Enjoi
const Joi = require("joi"); const Enjoi = require("enjoi"); const jsonSchema = { title: "User Detailed Output", allOf: [ { title: "User Basic Output", allOf: [ { type: "object", properties: { id: { type: "string", format: "uuid", description: "Kaydın ID'si." }, }, required: ["id"], }, { title: "User Common", type: "object", properties: { businessUnitId: { type: "string", format: "uuid", }, }, }, ], }, { type: "object" }, ], $schema: "http://json-schema.org/draft-04/schema#", }; Joi.assert({}, Enjoi.schema(jsonSchema));
ValidationError: { "id" [1]: -- missing -- } [1] "undefined" is required
ValidationError: { "id" [1]: -- missing -- } [1] "id" is required
Hi,
If
name
property is not present in schema, field name in thrown error (by Joi) isundefined
.It may not be a bug (name property is already missing), but during conversion
Enjoi
may use property key as field name if it is not present.Sample code:
Actual Output
Expected Output