Trait Yiisoft\Validator\Rule\Trait\CountableLimitTrait
| Implemented by | Yiisoft\Validator\Rule\Count, Yiisoft\Validator\Rule\Length |
|---|
An implementation for CountableLimitInterface intended to be included in rules. The following arguments need to be added in constructor and passed with initLimitProperties() call:
public function __construct(
// ...
int|null $min = null,
int|null $max = null,
int|null $exactly = null,
string $lessThanMinMessage = 'Less than {min}.',
string $greaterThanMinMessage = 'Greater than {max}.',
string $greaterThanMinMessage = 'Not exactly {exactly}.',
// ...
) {
// ...
$this->initLimitProperties(
$min,
$max,
$exactly,
$lessThanMinMessage,
$greaterThanMaxMessage,
$notExactlyMessage,
);
// ...
}
Also, if a rule implements \Yiisoft\Validator\Rule\Trait\DumpedRuleInterface, you can merge limit related options instead of adding it manually:
public function getOptions(): array
{
return array_merge($this->getLimitOptions(), [
// Other rule options.
]);
}
Make sure to include Yiisoft\Validator\Rule\Trait\CountableLimitHandlerTrait in according handler as well.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| getExactly() | A getter for $exactly property. | Yiisoft\Validator\Rule\Trait\CountableLimitTrait |
| getGreaterThanMaxMessage() | A getter for $greaterThanMaxMessage property. | Yiisoft\Validator\Rule\Trait\CountableLimitTrait |
| getLessThanMinMessage() | A getter for $lessThanMinMessage property. | Yiisoft\Validator\Rule\Trait\CountableLimitTrait |
| getMax() | A getter for $max property. | Yiisoft\Validator\Rule\Trait\CountableLimitTrait |
| getMin() | A getter for $min property. | Yiisoft\Validator\Rule\Trait\CountableLimitTrait |
| getNotExactlyMessage() | A getter for $notExactlyMessage property. | Yiisoft\Validator\Rule\Trait\CountableLimitTrait |
Method Details
A getter for $exactly property.
| public getExactly( ): integer|null | ||
| return | integer|null |
A number representing "exactly" value. |
|---|---|---|
public function getExactly(): ?int
{
return $this->exactly;
}
A getter for $greaterThanMaxMessage property.
| public getGreaterThanMaxMessage( ): string | ||
| return | string |
Validation error message. |
|---|---|---|
public function getGreaterThanMaxMessage(): string
{
return $this->greaterThanMaxMessage;
}
A getter for $lessThanMinMessage property.
| public getLessThanMinMessage( ): string | ||
| return | string |
Validation error message. |
|---|---|---|
public function getLessThanMinMessage(): string
{
return $this->lessThanMinMessage;
}
A getter for $max property.
| public getMax( ): integer|null | ||
| return | integer|null |
A number representing maximum boundary. |
|---|---|---|
public function getMax(): ?int
{
return $this->max;
}
A getter for $min property.
| public getMin( ): integer|null | ||
| return | integer|null |
A number representing minimum boundary. |
|---|---|---|
public function getMin(): ?int
{
return $this->min;
}
A getter for $notExactlyMessage property.
| public getNotExactlyMessage( ): string | ||
| return | string |
Validation error message. |
|---|---|---|
public function getNotExactlyMessage(): string
{
return $this->notExactlyMessage;
}
Signup or Login in order to comment.