<?xml version="1.0" encoding="UTF-8"?>

<!--

 This file is part of the Sylius package.

 (c) Sylius Sp. z o.o.

 For the full copyright and license information, please view the LICENSE
 file that was distributed with this source code.

-->

<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/services/constraint-mapping-1.0.xsd">
    <class name="Sylius\Component\Promotion\Model\CatalogPromotionAction">
        <constraint name="Sylius\Bundle\PromotionBundle\Validator\Constraints\CatalogPromotionActionType">
            <option name="groups">sylius</option>
        </constraint>

        <constraint name="Sylius\Bundle\PromotionBundle\Validator\Constraints\CatalogPromotionActionGroup">
            <option name="groups">sylius</option>
        </constraint>

        <property name="type">
            <constraint name="NotBlank">
                <option name="message">sylius.catalog_promotion_action.type.not_blank</option>
                <option name="groups">sylius</option>
            </constraint>
        </property>
        <property name="configuration">
            <constraint name="Collection">
                <option name="groups">sylius_catalog_promotion_action_percentage_discount</option>
                <option name="fields">
                    <value key="amount">
                        <constraint name="NotBlank">
                            <option name="message">sylius.catalog_promotion_action.percentage_discount.not_number_or_empty</option>
                            <option name="groups">sylius_catalog_promotion_action_percentage_discount</option>
                        </constraint>
                        <constraint name="Type">
                            <option name="type">numeric</option>
                            <option name="message">sylius.catalog_promotion_action.percentage_discount.not_number_or_empty</option>
                            <option name="groups">sylius_catalog_promotion_action_percentage_discount</option>
                        </constraint>
                        <constraint name="Range">
                            <option name="min">0</option>
                            <option name="max">1</option>
                            <option name="notInRangeMessage">sylius.catalog_promotion_action.percentage_discount.not_in_range</option>
                            <option name="groups">sylius_catalog_promotion_action_percentage_discount</option>
                        </constraint>
                    </value>
                </option>
                <option name="allowExtraFields">true</option>
            </constraint>
        </property>
    </class>
</constraint-mapping>
