Zend Framework seems to have a feature for validating integers (checked the /Validate/Int.php in the library for the purpose) which validates correctly float numbers as integer, while I want to show error when float number is given.
Here is a snippet from my form:
$form['my_int'] = new Zend_Form_Element_Text('my_int');
$form['my_int']->setLabel('My Int')
->setRequired(true)
->addFilter('StringTrim')
->addDecorator('Errors', array('placement'=>'prepend',
'class'=>'my-err'))
->addValidator('NotEmpty', true, array('messages' =>
array('isEmpty' => 'Please provide data')))
->addValidator('int', true, array(
'locale' => 'en_US',
'messages' => array(
'intInvalid' => 'Please provide valid data',
'notInt' => 'Please provide valid data'
)
));
So when I provide something different from string, integer or float, 'intInvalid' error is triggered and my custom message is shown. When float number like 1.23 is provided 'notInt' error is shown. The problem is when you provide e.g. 1.00, then the validator checks for "!Zend_Locale_Format::isInteger($value, array('locale' => $this->_locale))" and decides the input is integer and when you try to add float number in the the database in an integer field, you get error.
How should I organize my form validation so that when float number is provided, no matter what, to show error to the user?