constraint-mapping.xml 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. <!-- Constraint without value -->
  8. <constraint name="NotNull" />
  9. <!-- Custom constraint -->
  10. <constraint name="Symfony\Tests\Component\Validator\Fixtures\ConstraintA" />
  11. <!-- Constraint with single value -->
  12. <constraint name="Min">3</constraint>
  13. <!-- Constraint with multiple values -->
  14. <constraint name="Choice">
  15. <value>A</value>
  16. <value>B</value>
  17. </constraint>
  18. <!-- Constraint with child constraints -->
  19. <constraint name="All">
  20. <constraint name="NotNull" />
  21. <constraint name="Min">3</constraint>
  22. </constraint>
  23. <!-- Option with child constraints -->
  24. <constraint name="All">
  25. <option name="constraints">
  26. <constraint name="NotNull" />
  27. <constraint name="Min">3</constraint>
  28. </option>
  29. </constraint>
  30. <!-- Value with child constraints -->
  31. <constraint name="Collection">
  32. <option name="fields">
  33. <value key="foo">
  34. <constraint name="NotNull" />
  35. <constraint name="Min">3</constraint>
  36. </value>
  37. <value key="bar">
  38. <constraint name="Min">5</constraint>
  39. </value>
  40. </option>
  41. </constraint>
  42. <!-- PROPERTY CONSTRAINTS -->
  43. <property name="firstName">
  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>