I want to validate some parameter in my code, I wanna be sure that params value is an integer. I know that in Phalcon I have build in mechanism that allow me to validate params.
e.g:
class NumberValidator extends Validation
{
public function initialize()
{
$this->add('number', new RegexValidator(
array(
'pattern' => '^[0-9]+$',
'message' => 'Should be an integer number.'
)
)
);
}
}
now if I want validate that my variable $number is a number I should execute:
$numberVal = new Validators\NumberValidator();
$numberVal->validate(array('number' => $myParam));
My question is: Is there a way to validate only the parameter value without providing a parameter name. For example, if I want to be sure that the value of my parameter (any parameter) is integer I will execute:
<?php
$numberVal = new Validators\NumberValidator();
$numberVal->validate($myParam);