[bug] Convert empty string to null
szymonpoltorakrst opened this issue · comments
For object Ids (especially references) and arrays empty strings are sent from the form. They should be converted to null
or (if possible) to some more intelligent fallback values, for instance default value which is set in Schema
const DriverSchema = new Schema({
phone: {
type: String,
required: true,
},
busId: {
type: Schema.Types.ObjectId,
ref: 'Bus',
default: null,
},
});
For this model it is sent { phone: '', busId: '' }
when trying to sent empty form. This gives error ...cannot cast '' to ObjectID