Rule
class Rule
Traits
Constants
| UNDOTTED_DATA_CONTEXT_KEY |
CoroutineContext key for caching the undotted data in Rule::compile(). Set by ValidationRuleParser::explodeWildcardRulesCompilable() to avoid repeated Arr::undot() calls when Rule::forEach expands wildcard items. |
Properties
| static protected array | $macros | The registered string macros. |
from Macroable |
Methods
Mix another object into the class.
Dynamically handle calls to the class.
Dynamically handle calls to the class.
Apply the given rules if the given condition is truthy.
Apply the given rules if the given condition is falsy.
Get a unique constraint builder instance.
Get an exists constraint builder instance.
Get a dimensions rule builder instance.
Get a string rule builder instance.
Compile a set of rules for an attribute.
Flush all static state.
Details
in
Macroable at line 28
static void
macro(string $name, callable|object $macro)
Register a custom macro.
Boot-only. Macros persist in a static property for the worker lifetime and apply to every subsequent call on the macroable class.
in
Macroable at line 41
static void
mixin(object $mixin, bool $replace = true)
Mix another object into the class.
Boot-only. Delegates to macro() for each method; registered macros persist in a static property for the worker lifetime.
in
Macroable at line 57
static bool
hasMacro(string $name)
Check if macro is registered.
in
Macroable at line 68
static void
flushMacros()
Flush the existing macros.
Boot or tests only. Clears worker-wide macros; concurrent coroutines may resolve different methods depending on timing.
in
Macroable at line 78
static mixed
__callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
in
Macroable at line 103
mixed
__call(string $method, array $parameters)
Dynamically handle calls to the class.
at line 56
static Can
can(string $ability, mixed ...$arguments)
Get a can constraint builder instance.
at line 64
static ConditionalRules
when(bool|callable $condition, array|Closure|Rule|string|ValidationRule $rules, array|Closure|Rule|string|ValidationRule $defaultRules = [])
Apply the given rules if the given condition is truthy.
at line 75
static ConditionalRules
unless(bool|callable $condition, array|Closure|Rule|string|ValidationRule $rules, array|Closure|Rule|string|ValidationRule $defaultRules = [])
Apply the given rules if the given condition is falsy.
at line 86
static ArrayRule
array(mixed $keys = null)
Get an array rule builder instance.
at line 94
static ArrayKeys
arrayKeys(array|Arrayable|UnitEnum|int|string $keys)
Get an array keys rule builder instance.
at line 102
static NestedRules
forEach(Closure $callback)
Create a new nested rule set.
at line 110
static Unique
unique(string $table, string $column = 'NULL')
Get a unique constraint builder instance.
at line 118
static Exists
exists(string $table, string $column = 'NULL')
Get an exists constraint builder instance.
at line 134
static NotIn
notIn(array|Arrayable|UnitEnum|string $values)
Get a not_in rule builder instance.
at line 142
static Contains
contains(array|Arrayable|UnitEnum|string $values)
Get a contains rule builder instance.
at line 150
static DoesntContain
doesntContain(array|Arrayable|UnitEnum|string $values)
Get a doesnt_contain rule builder instance.
at line 160
static RequiredIf
requiredIf(bool|Closure|null $callback)
Get a required_if rule builder instance.
at line 170
static RequiredUnless
requiredUnless(bool|Closure|null $callback)
Get a required_unless rule builder instance.
at line 180
static ExcludeIf
excludeIf(bool|Closure $callback)
Get an exclude_if rule builder instance.
at line 190
static ExcludeUnless
excludeUnless(bool|Closure $callback)
Get an exclude_unless rule builder instance.
at line 200
static ProhibitedIf
prohibitedIf(bool|Closure $callback)
Get a prohibited_if rule builder instance.
at line 210
static ProhibitedUnless
prohibitedUnless(bool|Closure $callback)
Get a prohibited_unless rule builder instance.
at line 218
static Date
date()
Get a date rule builder instance.
at line 226
static Date
dateTime()
Get a datetime rule builder instance.
at line 234
static Email
email()
Get an email rule builder instance.
at line 244
static Enum
enum(string $type)
Get an enum rule builder instance.
at line 252
static File
file()
Get a file rule builder instance.
at line 260
static ImageFile
imageFile(bool $allowSvg = false)
Get an image file rule builder instance.
at line 268
static Dimensions
dimensions(array $constraints = [])
Get a dimensions rule builder instance.
at line 276
static StringRule
string()
Get a string rule builder instance.
at line 284
static Numeric
numeric()
Get a numeric rule builder instance.
at line 294
static AnyOf
anyOf(array $rules)
Get an "any of" rule builder instance.
at line 302
static object
compile(string $attribute, mixed $rules, array|null $data = null)
Compile a set of rules for an attribute.
at line 333
static void
flushState()
Flush all static state.