constraint-mapping.xml 2.4 KB

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