Validation::alphameric
Check alphanumeric or not
Description
public boolean Validation::alphameric( string $name, mixed $value, [ mixed $code = '' ] )
Arguments
Name | Data type | Default | Remarks |
---|---|---|---|
$name | string | Item label | |
$value | mixed | Check field value | |
$code | mixed | "" | 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> は半角英数で入力してください"