validate()

in frontend/src/services/PromotionService.es6 [53:73]


    validate(promotion) {
        if (promotion.promotionType.a && promotion.promotionType.b && promotion.promotionType.a.name == promotion.promotionType.b.name) {
            return this.$q.reject(["Both promotions cannot be of the same type."])
        }
        return this.$http({
            method: 'POST',
            url: '/promotion/validate',
            data: promotion
        }).then(() => {
              return this.$q.resolve(promotion);
          },
          errorResponse => {
            if (errorResponse.status === 400) {
              return this.$q.reject(Object.keys(errorResponse.data).map(f =>
                f + ": " + errorResponse.data[f].map(e => e.msg.join(" ")).join(" ")
              ));
            } else {
                return this.$q.reject([errorResponse.data.failureReason]);
            }
        })
    }