Welcome Guest, Not a member yet? Register   Sign In
(Bug?) Form_validation -> required
#1

[eluser]_xammax_[/eluser]
With:

Code:
// CI: 1.7.2 / PHP 5.1.2
// in validation rules I have 'required|is_natural'

$_POST = array('foo' => 0);

... and validation process fails. Only workaround is :

Code:
$_POST = array('foo' => '0');

// or

$_POST = array('foo' => (string) 0);

It sounds like a bug ... Anyone can confirm this please?
#2

[eluser]WanWizard[/eluser]
I'm not sure it's a bug.

Most is_??? tests work with a preg_match() which requires a string as input.

As this is about form validation, and form variables are always strings, this should not be an issue. It becomes different when you start faking form input by manually adding elements to $_POST.
#3

[eluser]_xammax_[/eluser]
[quote author="WanWizard" date="1274744938"]
Most is_??? tests work with a preg_match() which requires a string as input.
[/quote]

Opss ... On my prev post I've missed to say that is "required" rule that fails ...

Anyway you're right, in "real" _POST context it seems to work fine (infact I've found this when manually fill _POST array for testing purpose).
#4

[eluser]WanWizard[/eluser]
That's strange, because the Form validation library does:
Code:
if (isset($_POST[$field]) AND $_POST[$field] != "")




Theme © iAndrew 2016 - Forum software by © MyBB