Closed s-ohnishi closed 2 years ago
Can you give an example of a string that would fail this?
define form
class SampleForm extends \Phalcon\Forms\Form
public function initialize($entity = null, $options = [])
{
$elm = new Element\Text('foo');
$elm->addValidator(
new Validator\Numericality([
'message'=>'enter numeric value, please',
'allowEmpty'=>true
]),
);
$this->add($elm);
}
}
in the controller
$SampleForm = new \App\Forms\SampleForm();
$ret = $SampleForm ->isValid($_POST);
results
$_POST['foo'] $res
'-12,000' true
'-12,0@0' true
'-12,0@@0' false
Would you like a sample like this?
Yes. Thank you. I will fix this shortly
Resolved in https://github.com/phalcon/cphalcon/pull/16071
Thank you @s-ohnishi
Validator\Numericality::validate() uses this regular expression according to .zep.
pattern = "/((^[-]?[0-9,]+(.[0-9]+)?$)|(^[-]?[0-9.]+(,[0-9]+)?$))/";
But isn't
(.[0-9]+)?
a mistake for(\.[0-9]+)?
?Details