Welcome Guest, Not a member yet? Register   Sign In
validation problem
#4

[eluser]xwero[/eluser]
I don't think your check will ever be true or will always be true. The way your $type[‘item’]==$type[‘value’] works if you add an array to as the parameter to the rule with the keys item and value. The type of a POST value is most of the time a string but because php has weak typing you can check if it's numeric too. The numeric rule is in the Validation library and it also as a few rules to check the formating of the string.

You could add a check to see if the value for the post key is an array but that is it so your function would look like this
Code:
function($val,$type)
{
    $types = array('string','numeric','float','array');

    if( ! in_array($type,$types))
    {
       return FALSE;
    }

    $function = 'is_'.$type;

    if( ! $function($val))
    {
       return FALSE;
    }

    return TRUE;
}


Messages In This Thread
validation problem - by El Forum - 10-06-2008, 07:04 AM
validation problem - by El Forum - 10-06-2008, 07:12 AM
validation problem - by El Forum - 10-06-2008, 07:18 AM
validation problem - by El Forum - 10-06-2008, 07:26 AM
validation problem - by El Forum - 10-06-2008, 07:29 AM
validation problem - by El Forum - 10-06-2008, 07:48 AM
validation problem - by El Forum - 10-06-2008, 10:41 AM



Theme © iAndrew 2016 - Forum software by © MyBB