Validation::hankaku
Check that a value has only half-width characters
Description
public boolean Validation::hankaku( string $name, mixed $value, [ mixed $code = '' ] )
Valid when the value contains no multi-byte character (the byte length equals the character length).
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->hankaku('success', 'abc-123', array('@hankaku', 'Code')); // -> true
$validation->hankaku('failed', 'abc', array('@hankaku', 'Code')); // -> false
var_dump($validation->getErrorMessage());
// -> array('failed' => '<strong>Code</strong> は半角で入力してください')