Validation::email
Check the format of an email address
Description
public boolean Validation::email( string $name, mixed $value, [ mixed $code = '' ] )
Valid when the value looks like an email address (local@domain.tld, the top level domain having 2 letters or more).
Arguments
| Name | Data type | Default | Remarks |
|---|---|---|---|
| $name | string | Field name (key of the error message) | |
| $value | mixed | Value to check | |
| $code | mixed | '' | Error code, array of error code and parameters, or error message (see Configuration) |
Example
Controller
use Fegg\Tool\Validation;
$validation = new Validation();
$validation->email('success', 'foo@example.com', array('@email', 'Email')); // -> true
$validation->email('failed', 'foo@example', array('@email', 'Email')); // -> false
var_dump($validation->getErrorMessage());
// -> array('failed' => '<strong>Email</strong> は登録できない形式です')