Ticket #582 (closed defect: fixed)
Named validators clash
| Reported by: | MikeSeth | Owned by: | dominik |
|---|---|---|---|
| Priority: | normal | Milestone: | 0.11 |
| Component: | validation | Version: | 0.11.0RC5 |
| Severity: | major | Keywords: | validation conflict clash read write |
| Cc: | Patch attached: |
Description
It is impossible to have validators with the same name in both read and write contexts of an action. The validators are read linearly, and write validators override read validators with the same name. However, write validators only respond to write methods and so would not be executed by the validation manager in a read action. In other words, a read validator with the same name as a write validator would not work.
For example, in this configuration the read validation would be queried because validator names are different :
<validators method="read">
<validator class="isnotempty" name="username_present" severity="error" required="true">
<argument>username</argument>
</validator>
</validators>
<validators method="write">
<validator class="isnotempty" name="no_username" severity="error" required="true">
<argument>username</argument>
</validator>
</validators>
However, in this configuration the names are the same and so the read validator would not be executed in read context:
<validators method="read">
<validator class="isnotempty" name="no_username" severity="error" required="true">
<argument>username</argument>
</validator>
</validators>
<validators method="write">
<validator class="isnotempty" name="no_username" severity="error" required="true">
<argument>username</argument>
</validator>
</validators>

