Reputation: 21
Meteor v 1.10.1. I am using [email protected] and using simpl-schema v1.5.7 (NPM package)
I have this schema:
import SimpleSchema from "simpl-schema";
Orders.schema = new SimpleSchema ({
name: {
type: String
},
items: {
type: Array
},
"items.$": {
type: Object,
Blackbox: true
},
orderTax: {
type: Number,
optional: true,
autoValue: function () {
if(this.isInsert || this.isUpdate) {
return 0.5
}
}
total: {
type: Number,
optional: true,
autoValue: function () {
if(this.isInsert || this.isUpdate) {
const tax = this.field('orderTax').value;
// Here tax is undefined
}
}
})
orderTax is not sent as part of the object for simple-schema clean(), and yes that is the expected behavior, orderTax should only be computed for by the autoValue function on orderTax.
How do I use the autoValue computed from orderTax in total autoValue computation?
This setup works with earlier version of collection2 and earlier version aldeed:simple-schema (not NPM package)
Upvotes: 1
Views: 84