简体   繁体   中英

Validation Parameter Get Method in fuelphp

i have a problem when i want to validate using GET Method in fuelphp

i'm looking up in this documentation

// run validation on just post
if ($val->run())
{
    // process your stuff when validation succeeds
}
else
{
    // validation failed
}

that's code only validate if the method is Post or default post.

how to validate method get?

To run the validation against an array:

if ($val->run( array( $validation_rule => $value_to_validate) ))  
{  
     // process your stuff when validation succeeds  
}
else  
{
     // validation failed
}

Example:

$val = Validation::factory();
$val->add('email')->add_rule('valid_email');

if ($val->run( array('email'=>$email) ))
{
    // $email is valid
}
else
{
    // $email is not valid
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM