Skip to main content
Version: Fegg 5.x

Validation::userid

Check the format of a user ID

Description​

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

Valid when the value contains only 0-9, a-z, A-Z, -, _ and ..

Arguments​

NameData typeDefaultRemarks
$namestringField name (key of the error message)
$valuemixedValue to check
$codemixed''Error code, array of error code and parameters, or error message (see Configuration)

Example​

Controller
use Fegg\Tool\Validation;

$validation = new Validation();

$validation->userid('success', 'john.doe_01', '<strong>User ID</strong> は登録できない形式です'); // -> true
$validation->userid('failed', 'john doe', '<strong>User ID</strong> は登録できない形式です'); // -> false

var_dump($validation->getErrorMessage());
// -> array('failed' => '<strong>User ID</strong> は登録できない形式です')
note

The default validation_error_message.php has no @userid code. Pass the error message itself, or add the code to your site/config/validation_error_message.php.