php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57367 min_range and max_range options do not work for FILTER_VALIDATE_INT
Submitted: 2006-11-10 11:18 UTC Modified: 2006-11-10 11:35 UTC
From: ramsey@php.net Assigned:
Status: Not a bug Package: filter (PECL)
PHP Version: 5.2.0 OS: Mac OS X 10.4.8
Private report: No CVE-ID: None
 [2006-11-10 11:18 UTC] ramsey@php.net
Description:
------------
When using FILTER_VALIDATE_INT, the min_range and max_range options seem to have no effect. The integer is returned, regardless.

Perhaps there is a problem with FETCH_LONG_OPTION() and even FETCH_STRING_OPTION() (as perhaps indicated by my comment on 2006-11-10 16:08 UTC here: http://pecl.php.net/bugs/bug.php?id=5975).

Reproduce code:
---------------
<?php

// $_GET['age'] = '0'
$age = 102;

$options = array('min_range' => 1, 'max_range' => 100);

var_dump(filter_input(INPUT_GET, 'age', FILTER_VALIDATE_INT, $options));

var_dump(filter_var($age, FILTER_VALIDATE_INT, $options));

?>

Expected result:
----------------
bool(false)
bool(false)

Actual result:
--------------
int(0)
int(102)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-11-10 11:19 UTC] ramsey@php.net
Changing version from 5.2.0 RC4 to 5.2.0 (for some reason, the bug report form wouldn't allow me to use 5.2.0).
 [2006-11-10 11:35 UTC] ramsey@php.net
This is bogus because I was providing the options arguments incorrectly.

They should be passed like this:

array('options' => array('min_range' => 1, 'max_range' => 100))
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 19:01:29 2024 UTC