class ConditionalRules (View source)

Properties

protected callable|bool $condition

The boolean condition indicating if the rules should be added to the attribute.

protected array|string $rules

The rules to be added to the attribute.

protected array|string $defaultRules

The rules to be added to the attribute if the condition fails.

Methods

void
__construct(callable|bool $condition, array|string $rules, array|string $defaultRules = [])

Create a new conditional rules instance.

bool
passes(array $data = [])

Determine if the conditional rules should be added.

array
rules()

Get the rules.

array
defaultRules()

Get the default rules.

Details

void __construct(callable|bool $condition, array|string $rules, array|string $defaultRules = [])

Create a new conditional rules instance.

Parameters

callable|bool $condition
array|string $rules
array|string $defaultRules

Return Value

void

bool passes(array $data = [])

Determine if the conditional rules should be added.

Parameters

array $data

Return Value

bool

array rules()

Get the rules.

Return Value

array

array defaultRules()

Get the default rules.

Return Value

array

Laravel Cloud is the best place to deploy Laravel, Nuxt, Express, Hono, Node.js, Bun, Go, Flask, Python, and more, with dedicated infrastructure available on AWS through Laravel Private Cloud.