Skip to main content

Validation::alphameric

Check alphanumeric or not

Description

public boolean Validation::alphameric( 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 not alphanumeric
$successName = 'Success Field';
$successVar = 'abc123';
$validation->alphameric('success', $successVar, array('@alphameric', $successName));

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

// If $value is not alphanumeric
$failedName = 'Failed Field';
$failedVar = 'abc!';
$validation->alphameric('failed', $failedVar, array('@alphameric', $failedName));

var_dump($validation->isError()); // -> true
var_dump($validation->getErrorMessage());
// -> "failed" => "<strong>Failed Field</strong> は半角英数で入力してください"