Validation::minlength
Check character more than minimum length
Description
public boolean Validation::minlength( string $name, mixed $value, numeric $length, [ mixed $code = '' ] )
Arguments
Name | Data type | Default | Remarks |
---|---|---|---|
$name | string | Item label | |
$value | mixed | Check field value | |
$length | numeric | Specific length value | |
$code | mixed | "" | Error code or Error message |
Example
Controller
$validation = $this->getClass('Validation');
// If $value is more than specific length
$successName = 'Success Field';
$successVar = 'foo';
$length = 1;
$validation->minlength('success', $successVar, $length, array('@minlength', $successName, $length));
var_dump($validation->isError()); // -> false
var_dump($validation->getErrorMessage()); // -> null
// If $value is less than equal specific length
$failedName = 'Failed Field';
$failedVar = 'failed';
$length = 10;
$validation->minlength('failed', $failedVar, $length, array('@minlength', $failedName, $length));
var_dump($validation->isError()); // -> true
var_dump($validation->getErrorMessage());
// -> "failed" => "<strong>Failed Field</strong> は <strong>10</strong> 文字以上で入力してください"