Between Validator outputs true for characters
Closed this issue · 3 comments
koseduhemak commented
Hi,
I am using version "2.9.0 - 2017-03-17" of zendframework/zend-validator.
If I input string "asdasd" for field "price" validator returns true. Expecting: false.
String "asdasd" is not even a number. Therefore it cannot lie between 0 and 99999999.
public function init() { $this->add(array( 'type' => 'text', 'name' => 'price', 'options' => array( 'label' => $this->translator->translate('label.price', 'Form'), 'label_attributes' => array( 'class' => 'col-sm-3', ), 'column-size' => 'sm-5', ), 'attributes' => array( 'id' => 'price', ), )); } public function getInputFilterSpecification() { return array( 'price' => array( 'required' => true, 'validators' => array( array( 'name' => 'Between', 'options' => array( 'min' => 0, 'max' => 99999999, 'inclusive' => true ), ), ), ), ); }
Ocramius commented
It most likely evaluates as 1
via implicit cast. What happens if 'min'
is 2
?
koseduhemak commented
if I use 2
it works as expected. How can I change implicit casting behavior to check in a typesafe way? I am struggling to validate integer / float input in my text fields...
Ocramius commented
@koseduhemak I'd say it needs to be considered a bug, given a failing test case and fixed.