53 lines
1,013 B
PHP
53 lines
1,013 B
PHP
<?php
|
|
|
|
namespace ctiso\Validator\Rule;
|
|
use ctiso\Collection;
|
|
|
|
abstract class AbstractRule
|
|
{
|
|
public string $field;
|
|
protected ?string $errorMsg;
|
|
protected $ctx;
|
|
|
|
public function __construct(string $field, ?string $errorMsg = null)
|
|
{
|
|
$this->field = $field;
|
|
$this->errorMsg = $errorMsg;
|
|
}
|
|
|
|
public function setName(string $field): self
|
|
{
|
|
$this->field = $field;
|
|
return $this;
|
|
}
|
|
|
|
public function setErrorMsg(?string $errorMsg): self
|
|
{
|
|
$this->errorMsg = $errorMsg;
|
|
return $this;
|
|
}
|
|
|
|
public function getErrorMsg(): string
|
|
{
|
|
return $this->errorMsg;
|
|
}
|
|
|
|
/**
|
|
* @param Collection $container
|
|
* @param bool|null $status
|
|
* @return bool
|
|
*/
|
|
public function isValid(Collection $container, $status = null): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
function skipEmpty(): bool {
|
|
return true;
|
|
}
|
|
|
|
public function setContext($ctx): void
|
|
{
|
|
$this->ctx = $ctx;
|
|
}
|
|
}
|