メインコンテンツまでスキップ

Validation::email

Check valid E-mail string

Description

public boolean Validation::email( string $name, mixed $value, [ mixed $code = '' ] )

Arguments

NameData typeDefaultRemarks
$namestringItem label
$valuemixedCheck field value
$codemixed""Error code or Error message

Example

Controller
$validation = $this->getClass('Validation');

// If $value is E-mail string
$successName = 'Success Field';
$successVar = 'email@example.com';
$validation->email('success', $successVar, array('@email', $successName));

var_dump($validation->isError()); // -> false
var_dump($validation->getErrorMessage()); // -> null

// If $value is not E-mail string
$failedName = 'Failed Field';
$failedVar = 'Something not email text';
$validation->email('failed', $failedVar, array('@email', $failedName));

var_dump($validation->isError()); // -> true
var_dump($validation->getErrorMessage());
// -> "failed" => "<strong>Failed Field</strong> は登録できない形式です"