constraint-mapping.xml 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?xml version="1.0" ?>
  2. <constraint-mapping xmlns="http://www.symfony-project.org/schema/dic/constraint-mapping"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xsi:schemaLocation="http://www.symfony-project.org/schema/dic/constraint-mapping http://www.symfony-project.org/schema/dic/services/constraint-mapping-1.0.xsd">
  5. <class name="Symfony\Tests\Component\Validator\Fixtures\Entity">
  6. <!-- CLASS CONSTRAINTS -->
  7. <!-- Custom constraint -->
  8. <constraint name="Symfony\Tests\Component\Validator\Fixtures\ConstraintA" />
  9. <!-- PROPERTY CONSTRAINTS -->
  10. <property name="firstName">
  11. <!-- Constraint without value -->
  12. <constraint name="NotNull" />
  13. <!-- Constraint with single value -->
  14. <constraint name="Min">3</constraint>
  15. <!-- Constraint with multiple values -->
  16. <constraint name="Choice">
  17. <value>A</value>
  18. <value>B</value>
  19. </constraint>
  20. <!-- Constraint with child constraints -->
  21. <constraint name="All">
  22. <constraint name="NotNull" />
  23. <constraint name="Min">3</constraint>
  24. </constraint>
  25. <!-- Option with child constraints -->
  26. <constraint name="All">
  27. <option name="constraints">
  28. <constraint name="NotNull" />
  29. <constraint name="Min">3</constraint>
  30. </option>
  31. </constraint>
  32. <!-- Value with child constraints -->
  33. <constraint name="Collection">
  34. <option name="fields">
  35. <value key="foo">
  36. <constraint name="NotNull" />
  37. <constraint name="Min">3</constraint>
  38. </value>
  39. <value key="bar">
  40. <constraint name="Min">5</constraint>
  41. </value>
  42. </option>
  43. </constraint>
  44. <!-- Constraint with options -->
  45. <constraint name="Choice">
  46. <!-- Option with single value -->
  47. <option name="message">Must be one of %choices%</option>
  48. <!-- Option with multiple values -->
  49. <option name="choices">
  50. <value>A</value>
  51. <value>B</value>
  52. </option>
  53. </constraint>
  54. </property>
  55. <!-- GETTER CONSTRAINTS -->
  56. <getter property="lastName">
  57. <constraint name="NotNull" />
  58. </getter>
  59. </class>
  60. </constraint-mapping>