Hello,
Me, again…!
I use Simple Schema and I have defined this :
// My schema
// ...
ip: {
type: String,
label: 'Adresse IP',
regEx: SimpleSchema.RegEx.IP,
},
port: {
type: Number,
min: 0,
label: 'Port Modbus TCP-IP',
defaultValue: 502,
// Same error with autoValue: () => 502,
},
When I add a document with Factory -> no error.
But when I use ValidatedMethod, I have an error with fields with “defaultValue”.
I’m adding this document :
// ...
connection: {
ip: faker.internet.ip(),
},
The method is the folling :
export const insert = new ValidatedMethod({
name: 'equipments.insert',
validate: new SimpleSchema({
newEquipment: {
type: Equipments.simpleSchema().omit('_id'), //
},
}).validator({ clear: true }),
run({ newEquipment }) {
if (!this.userId) {
throw new Meteor.Error('equipments.insert.not-logged-in', 'Must be logged in to create invoice.');
}
console.log('equipments.insert');
console.log(newEquipment);
Equipments.insert(newEquipment, { validate: false });
},
});
And I have this error :
Error: Port Modbus TCP-IP is required [validation-error]
And on each field if I deleted this one.
Any idea ?
Thanks