constraint-mapping.xml 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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\Components\Validator\Fixtures\Entity">
  6. <!-- CLASS CONSTRAINTS -->
  7. <!-- Constraint without value -->
  8. <constraint name="NotNull" />
  9. <!-- Constraint with single value -->
  10. <constraint name="Min">3</constraint>
  11. <!-- Constraint with multiple values -->
  12. <constraint name="Choice">
  13. <value>A</value>
  14. <value>B</value>
  15. </constraint>
  16. <!-- Constraint with child constraints -->
  17. <constraint name="All">
  18. <constraint name="NotNull" />
  19. <constraint name="Min">3</constraint>
  20. </constraint>
  21. <!-- Option with child constraints -->
  22. <constraint name="All">
  23. <option name="constraints">
  24. <constraint name="NotNull" />
  25. <constraint name="Min">3</constraint>
  26. </option>
  27. </constraint>
  28. <!-- Value with child constraints -->
  29. <constraint name="Collection">
  30. <option name="fields">
  31. <value key="foo">
  32. <constraint name="NotNull" />
  33. <constraint name="Min">3</constraint>
  34. </value>
  35. <value key="bar">
  36. <constraint name="Min">5</constraint>
  37. </value>
  38. </option>
  39. </constraint>
  40. <!-- PROPERTY CONSTRAINTS -->
  41. <property name="firstName">
  42. <!-- Constraint with options -->
  43. <constraint name="Choice">
  44. <!-- Option with single value -->
  45. <option name="message">Must be one of %choices%</option>
  46. <!-- Option with multiple values -->
  47. <option name="choices">
  48. <value>A</value>
  49. <value>B</value>
  50. </option>
  51. </constraint>
  52. </property>
  53. <!-- GETTER CONSTRAINTS -->
  54. <getter property="lastName">
  55. <constraint name="NotNull" />
  56. </getter>
  57. </class>
  58. </constraint-mapping>