<?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\Addressing\Model\Zone">
        <constraint name="Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity">
            <option name="fields">code</option>
            <option name="message">sylius.zone.code.unique</option>
            <option name="groups">sylius</option>
        </constraint>
        <property name="code">
            <constraint name="NotBlank">
                <option name="message">sylius.zone.code.not_blank</option>
                <option name="groups">sylius</option>
            </constraint>
            <constraint name="Regex">
                <option name="message">sylius.zone.code.regex</option>
                <option name="pattern">/^[\w-]*$/</option>
                <option name="groups">sylius</option>
            </constraint>
            <constraint name="Length">
                <option name="max">255</option>
                <option name="maxMessage">sylius.zone.code.max_length</option>
                <option name="groups">sylius</option>
            </constraint>
        </property>
        <property name="scope">
            <constraint name="NotBlank">
                <option name="message">sylius.zone.scope.not_blank</option>
                <option name="groups">sylius</option>
            </constraint>
        </property>
        <property name="name">
            <constraint name="NotBlank">
                <option name="message">sylius.zone.name.not_blank</option>
                <option name="groups">sylius</option>
            </constraint>
            <constraint name="Length">
                <option name="min">2</option>
                <option name="max">255</option>
                <option name="minMessage">sylius.zone.name.min_length</option>
                <option name="maxMessage">sylius.zone.name.max_length</option>
                <option name="groups">sylius</option>
            </constraint>
        </property>
        <getter property="members">
            <constraint name="Sylius\Bundle\ResourceBundle\Validator\Constraints\UniqueWithinCollectionConstraint">
                <option name="message">sylius.zone_member.unique</option>
                <option name="groups">sylius</option>
            </constraint>
            <constraint name="Sylius\Bundle\AddressingBundle\Validator\Constraints\ZoneCannotContainItself">
                <option name="message">sylius.zone_member.cannot_be_the_same_as_zone</option>
                <option name="groups">
                    <value>sylius</value>
                </option>
            </constraint>
            <constraint name="Valid" />
            <constraint name="Count">
                <option name="min">1</option>
                <option name="minMessage">sylius.zone.members.min_count</option>
                <option name="groups">sylius</option>
            </constraint>
        </getter>
    </class>
</constraint-mapping>
