private function validateDiscount(array $payload, ConstraintViolationList $violationList)
    {
        /** @var string $type */
        $type = $this->getValue($payload, 'type', '');

        /** @var float|null $value */
        $value = $this->getValue($payload, 'value', null);

        if ($value === null) {
            return;
        }

        if ($value < self::DISCOUNT_MIN_VALUE) {
            $violationList->add($this->buildViolation('Value must not be less than ' . self::DISCOUNT_MIN_VALUE, $value));
        }

        switch ($type) {
            case PromotionDiscountEntity::TYPE_PERCENTAGE:
                if ($value > self::DISCOUNT_PERCENTAGE_MAX_VALUE) {
                    $violationList->add($this->buildViolation('Absolute value must not greater than ' . self::DISCOUNT_PERCENTAGE_MAX_VALUE, $value));
                }
                break;
        }
    }
private function validateDiscount(array $payload, ConstraintViolationList $violationList)
    {
        /** @var string $type */
        $type = $this->getValue($payload, 'type', '');

        /** @var float|null $value */
        $value = $this->getValue($payload, 'value', null);

        if ($value === null) {
            return;
        }

        if ($value < self::DISCOUNT_MIN_VALUE) {
            $violationList->add($this->buildViolation('Value must not be less than ' . self::DISCOUNT_MIN_VALUE, $value));
        }

        switch ($type) {
            case PromotionDiscountEntity::TYPE_PERCENTAGE:
                if ($value > self::DISCOUNT_PERCENTAGE_MAX_VALUE) {
                    $violationList->add($this->buildViolation('Absolute value must not greater than ' . self::DISCOUNT_PERCENTAGE_MAX_VALUE, $value));
                }
                break;
        }
    }
private function validateDiscount ( array $ payload , ConstraintViolationList $ violationList ) { /** @var string $type */ $ type = $ this -> getValue ( $ payload , 'type' , '' ) ; /** @var float|null $value */ $ value = $ this -> getValue ( $ payload , 'value' , null ) ; if ( $ value === null ) { return ; } if ( $ value < self :: DISCOUNT_MIN_VALUE ) { $ violationList -> add ( $ this -> buildViolation ( 'Value must not be less than ' . self :: DISCOUNT_MIN_VALUE , $ value ) ) ; } switch ( $ type ) { case PromotionDiscountEntity :: TYPE_PERCENTAGE : if ( $ value > self :: DISCOUNT_PERCENTAGE_MAX_VALUE ) { $ violationList -> add ( $ this -> buildViolation ( 'Absolute value must not greater than ' . self :: DISCOUNT_PERCENTAGE_MAX_VALUE , $ value ) ) ; } break ; } }
Validates the provided PromotionDiscount data and adds
violations to the provided list of violations, if found.

@param array                   $payload       the incoming delta-data
@param ConstraintViolationList $violationList the list of violations that needs to be filled
Validates the provided PromotionDiscount data and adds violations to the provided list of violations if found .