Re: Simple variable handling.
| From: | Yasuo Ohgaki | Date: | Fri, 12 Aug 2016 11:15:44 +0000 |
| Subject: | Re: Simple variable handling. | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-95094@lists.php.net to get a copy of this message | ||
Hi Lester,
On Fri, Aug 12, 2016 at 8:13 PM, Yasuo Ohgaki <yohgaki@ohgaki.net> wrote:
> On Fri, Aug 12, 2016 at 8:06 PM, Lester Caine <lester@lsces.co.uk> wrote:
>> On 12/08/16 11:51, Yasuo Ohgaki wrote:
>>> What makes you feel missing some or designed badly?
>>
>> I may be missing something, but I thought the original code had rules
>> for each element of the array? I would certainly expect to see the
>> capability of setting different validating rules for each element, and
>> the rules you are defining are the same rules that would be needed on a
>> variable by variable basis?
>
> You can do
>
> $get_def_for_an_api = array(
> 'date' => $my_date_spec,
> 'bookname' => $my_bookname_spec,
> 'isbn' => $my_isbn_spec,
> );
>
> filter_require_var_array($_GET, $get_def_for_an_api);
>
> One missing validation filter is "optional" filter. I may add this
> later or now before starting vote.
"optional" filter can be defined by "callback" filter without
dedicated filter for optional inputs, BTW.
Regards,
--
Yasuo Ohgaki
yohgaki@ohgaki.net