Skip to content

ErrorBag


  • Full name: \Qubus\Validation\ErrorBag

Properties

messages

protected array $messages

Methods

__construct

Constructor

public __construct(array $messages = []): void

Parameters:

Parameter Type Description
$messages array

add

Add message for given key and rule

public add(string $key, string $rule, string $message): void

Parameters:

Parameter Type Description
$key string
$rule string
$message string

count

Get messages count

public count(): int

has

Check given key is existed

public has(string $key): bool

Parameters:

Parameter Type Description
$key string

first

Get the first value of array

public first(string $key): mixed

Parameters:

Parameter Type Description
$key string

get

Get messages from given key, can be use custom format

public get(string $key, string $format = ':message'): array

Parameters:

Parameter Type Description
$key string
$format string

all

Get all messages

public all(string $format = ':message'): array

Parameters:

Parameter Type Description
$format string

firstOfAll

Get the first message from existing keys

public firstOfAll(string $format = ':message', bool $dotNotation = false): array

Parameters:

Parameter Type Description
$format string
$dotNotation bool

toArray

Get plain array messages

public toArray(): array

parseKey

Parse $key to get the array of $key and $ruleName

protected parseKey(string $key): array

Parameters:

Parameter Type Description
$key string

isWildcardKey

Check the $key is wildcard

protected isWildcardKey(mixed $key): bool

Parameters:

Parameter Type Description
$key mixed

filterMessagesForWildcardKey

Filter messages with wildcard key

protected filterMessagesForWildcardKey(string $key, mixed|null $ruleName = null): array

Parameters:

Parameter Type Description
$key string
$ruleName mixed|null

formatMessage

Get formatted message

protected formatMessage(string $message, string $format): string

Parameters:

Parameter Type Description
$message string
$format string