#1283: Allow extraction of subpatterns in regex validator
-------------------------+--------------------------------------------------
Reporter: david | Owner: dominik
Type: enhancement | Status: new
Priority: normal | Milestone: 1.0.4
Component: validation | Version: 1.0.3
Severity: normal | Keywords:
Has_patch: 0 |
-------------------------+--------------------------------------------------
Let's assume people in your company log into most systems with their email
address, but your app really only needs their username, so they're often
confused. Also, they tend to use leading and trailing spaces a lot.
{{{
#!xml
<validator class="regex">
<argument>username</argument>
<ae:parameter
name="pattern">#^\s*(?'user'.+)(@yourcompany\.com)?\s*$#u</ae:parameter>
<ae:parameter name="extract">user</ae:parameter>
<ae:parameter name="export">user</ae:parameter>
</validator>
}}}
That would export the extracted part before the {...@}}} into an argument
called "user".
You could also omit the {{{export}}} parameter; in that case, the
extracted value ends up in the original {{{username}}} argument (like
{{{AgaviNumberValidator}}} does).
This only works, of course, if the validator succeeded and the
{{{match}}} param is the default {{{true}}}.
--
Ticket URL: <http://trac.agavi.org/ticket/1283>
Agavi <http://www.agavi.org/>
An MVC Framework for PHP5
_______________________________________________
Agavi Tickets Mailing List
[email protected]
http://lists.agavi.org/mailman/listinfo/tickets