Version 3, last updated by pagchen at November 07, 2011 23:36 UTC

This wiki has been updated for version 0.7-alpha4

1. Filtering email addresses

// Get a filter object
$filter = KFilter::factory('email');

// Checking if a string is a valid email:
if( $filter->validate($email)) {
    echo "It's valid!";
}

// attempt to clean up a string into a valid email
if( $email = $filter->sanitize($email)) {
    echo "$email is now valid!";
} else {
   echo "Sorry, that string is too messed up!";
}

// Get a string from the request and sanitize it as email in one go
$email = KRequest::get('post.email', 'email');
if(!$email) {
   echo "The submitted email address is invalid, please try again";
}

Other examples:

// You can use KFactory to get a filter too
$filter = KFactory::get('lib.koowa.filter.email');

// Get and filter a variable using the full identifier for the filter
$email = KRequest::get('post.email', 'lib.koowa.filter.email');

// You can pass the filter as a variable
$filter = KFilter::factory('email');
$email = KRequest::get('post.email', $filter);