0 follower

Abstract Class Yiisoft\Validator\Rule\Date\BaseDate

InheritanceYiisoft\Validator\Rule\Date\BaseDate
ImplementsYiisoft\Validator\RuleInterface, Yiisoft\Validator\SkipOnEmptyInterface, Yiisoft\Validator\SkipOnErrorInterface, Yiisoft\Validator\WhenInterface
Uses TraitsYiisoft\Validator\Rule\Trait\SkipOnEmptyTrait, Yiisoft\Validator\Rule\Trait\SkipOnErrorTrait, Yiisoft\Validator\Rule\Trait\WhenTrait
SubclassesYiisoft\Validator\Rule\Date\Date, Yiisoft\Validator\Rule\Date\DateTime, Yiisoft\Validator\Rule\Date\Time

Psalm Types

Name Value
IntlDateFormatterFormat \IntlDateFormatter::FULL|\IntlDateFormatter::LONG|\IntlDateFormatter::MEDIUM|\IntlDateFormatter::SHORT|\IntlDateFormatter::NONE

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( string|null $format, string|null $timeZone, string|null $locale, integer|string|DateTimeInterface|null $min, integer|string|DateTimeInterface|null $max, string|null $messageFormat, string|null $incorrectInputMessage, string|null $tooEarlyMessage, string|null $tooLateMessage, boolean|callable|null $skipOnEmpty, boolean $skipOnError, Closure|null $when )
$format string|null
$timeZone string|null
$locale string|null
$min integer|string|DateTimeInterface|null
$max integer|string|DateTimeInterface|null
$messageFormat string|null
$incorrectInputMessage string|null
$tooEarlyMessage string|null
$tooLateMessage string|null
$skipOnEmpty boolean|callable|null
$skipOnError boolean
$when Closure|null

                public function __construct(
    private ?string $format,
    private ?string $timeZone,
    private ?string $locale,
    private int|string|DateTimeInterface|null $min,
    private int|string|DateTimeInterface|null $max,
    private ?string $messageFormat,
    private ?string $incorrectInputMessage,
    private ?string $tooEarlyMessage,
    private ?string $tooLateMessage,
    bool|callable|null $skipOnEmpty,
    private bool $skipOnError,
    private ?Closure $when,
) {
    $this->skipOnEmpty = $skipOnEmpty;
}

            
getFormat() public method

public string|null getFormat ( )

                public function getFormat(): ?string
{
    return $this->format;
}

            
getHandler() public abstract method

Defined in: Yiisoft\Validator\RuleInterface::getHandler()

A matching handler name or an instance used for processing this rule.

While not required, for naming of handlers' classes it's recommended to use a rule class name with "Handler" suffix, so for FilledAtLeast rule class name the handler class name will be FilledAtLeastHandler and so on.

All packages handlers are stored within the same namespace as rules, but this is not a strict requirement.

public abstract Yiisoft\Validator\RuleHandlerInterface|string getHandler ( )
return Yiisoft\Validator\RuleHandlerInterface|string

A rule handler name (for example my-handler) or an instance (for example new MyRuleHandler()).

                public function getHandler(): string|RuleHandlerInterface;

            
getIncorrectInputMessage() public method

public string|null getIncorrectInputMessage ( )

                public function getIncorrectInputMessage(): ?string
{
    return $this->incorrectInputMessage;
}

            
getLocale() public method

public string|null getLocale ( )

                public function getLocale(): ?string
{
    return $this->locale;
}

            
getMax() public method

public DateTimeInterface|integer|string|null getMax ( )

                public function getMax(): DateTimeInterface|int|string|null
{
    return $this->max;
}

            
getMessageFormat() public method

public string|null getMessageFormat ( )

                public function getMessageFormat(): ?string
{
    return $this->messageFormat;
}

            
getMin() public method

public DateTimeInterface|integer|string|null getMin ( )

                public function getMin(): DateTimeInterface|int|string|null
{
    return $this->min;
}

            
getName() public method

public string getName ( )

                public function getName(): string
{
    return 'date';
}

            
getSkipOnEmpty() public method

Defined in: Yiisoft\Validator\Rule\Trait\SkipOnEmptyTrait::getSkipOnEmpty()

A getter for $skipOnEmpty property.

public boolean|callable|null getSkipOnEmpty ( )
return boolean|callable|null

A current raw (non-normalized) value.

                public function getSkipOnEmpty(): bool|callable|null
{
    return $this->skipOnEmpty;
}

            
getTimeZone() public method

public non-empty-string|null getTimeZone ( )

                public function getTimeZone(): ?string
{
    return $this->timeZone;
}

            
getTooEarlyMessage() public method

public string|null getTooEarlyMessage ( )

                public function getTooEarlyMessage(): ?string
{
    return $this->tooEarlyMessage;
}

            
getTooLateMessage() public method

public string|null getTooLateMessage ( )

                public function getTooLateMessage(): ?string
{
    return $this->tooLateMessage;
}

            
getWhen() public method

Defined in: Yiisoft\Validator\Rule\Trait\WhenTrait::getWhen()

A getter for $when property.

public Closure|null getWhen ( )
return Closure|null

Current value:

  • null - always apply the validation.
  • callable - apply the validation depending on a return value: true - apply, false - do not apply.

                public function getWhen(): ?Closure
{
    return $this->when;
}

            
shouldSkipOnError() public method

Defined in: Yiisoft\Validator\Rule\Trait\SkipOnErrorTrait::shouldSkipOnError()

A getter for $skipOnError property.

public boolean shouldSkipOnError ( )
return boolean

Current value. true means to skip the current rule when the previous one errored and false - do not skip.

                public function shouldSkipOnError(): bool
{
    return $this->skipOnError;
}

            
skipOnEmpty() public method

Defined in: Yiisoft\Validator\Rule\Trait\SkipOnEmptyTrait::skipOnEmpty()

An immutable setter to change $skipOnEmpty property.

public $this skipOnEmpty ( boolean|callable|null $value )
$value boolean|callable|null

A new value.

return $this

The new instance with a changed value.

                public function skipOnEmpty(bool|callable|null $value): static
{
    $new = clone $this;
    $new->skipOnEmpty = $value;
    return $new;
}

            
skipOnError() public method

Defined in: Yiisoft\Validator\Rule\Trait\SkipOnErrorTrait::skipOnError()

An immutable setter to change $skipOnError property.

public $this skipOnError ( boolean $value )
$value boolean

A new value. true means to skip the current rule when the previous one errored and false - do not skip.

return $this

The new instance with a changed value.

                public function skipOnError(bool $value): static
{
    $new = clone $this;
    $new->skipOnError = $value;
    return $new;
}

            
when() public method

Defined in: Yiisoft\Validator\Rule\Trait\WhenTrait::when()

An immutable setter to change $when property.

public $this when ( Closure|null $value )
$value Closure|null

A new value:

  • null - always apply the validation.
  • callable - apply the validation depending on a return value: true - apply, false - do not apply.
return $this

The new instance with a changed value.

                public function when(?Closure $value): static
{
    $new = clone $this;
    $new->when = $value;
    return $new;
}