UNPKG

492 BJavaScriptView Raw
1const { exception } = require('q3-core-responder');
2const Decorator = require('./decorator');
3const Schema = require('./schema');
4
5Schema.loadClass(Decorator);
6
7Schema.pre('save', function conditionalRequirements() {
8 if (
9 (!this.couponCode && !this.requiredSkus) ||
10 (this.couponCode && this.requiredSkus)
11 )
12 exception('Validation')
13 .msg('codeOrSku')
14 .field('couponCode')
15 .field('requiredSkus')
16 .throw();
17});
18
19module.exports = Schema;