-
Notifications
You must be signed in to change notification settings - Fork 23
Open
Description
According to the Mongoose arrays documentation, an array default value is possible.
But in schm, when array of schema is validatate, the default value is always an empty array.
Inspired example from Mongoose
const ToySchema = schm({ name: String });
const ToyBoxSchema = schm({
toys: {
type: [ToySchema],
default: undefined
},
buffers: [Buffer],
strings: [String],
numbers: [Number]
});
const result = await ToyBoxSchema.validate({
// Validate empty object
});
console.log(result);
// result = { toys: [], buffers: [], strings: [], numbers: [] }
// Expected: result = { toys: undefined, buffers: [], strings: [], numbers: [] }
Any idea to get a custom default value rather than an empty array?
Thx
Metadata
Metadata
Assignees
Labels
No labels