V2:Shortcut Calls

From PhpInputValidator

Jump to: navigation, search

In phpInputValidator v2 shortcut calls to type methods can be used.

Take this example:

$uid = $getvar->get('uid', 'POST', 'int');

Instead you could use:

$uid = $getvar->int('uid', 'POST');


Any valid type can be used as a method. Some more examples could be:

$email_address = $getvar->email('email_address', 'POST');
$amount = $getvar->float('amount', 'POST', array('default' => '34.55'));
$credit_card = $getvar->credit_card('credit_card', 'POST');
$message = $getvar->string('credit_card', 'POST', array('purify' => _PIV_VAR_PURIFY), array('multibyte' => false));

These shortcut still take the same parameter except the type.