Validation::userId
Check allowed character for UserID (- _ . 0-9)
Description
public boolean Validation::userId( 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 UserID string
$successName = 'Success Field';
$successVar = 'user_id123456';
$validation->userId('success', $successVar, array('@userid', $successName));
var_dump($validation->isError()); // -> false
var_dump($validation->getErrorMessage()); // -> null
// If $value is not UserID string
$failedName = 'Failed Field';
$failedVar = 'not*user_id/123456';
$validation->userId('failed', $failedVar, array('@userid', $failedName));
var_dump($validation->isError()); // -> true
var_dump($validation->getErrorMessage());
// -> "failed" => "<strong>Failed Field</strong> は登録できない形式です"