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|InvokableRule|Rule|string|ValidationRule $rules, array|Closure|InvokableRule|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|InvokableRule|Rule|string|ValidationRule $rules, array|Closure|InvokableRule|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 NestedRules
forEach(Closure $callback)
Create a new nested rule set.
at line 102
static Unique
unique(string $table, string $column = 'NULL')
Get a unique constraint builder instance.
at line 110
static Exists
exists(string $table, string $column = 'NULL')
Get an exists constraint builder instance.
at line 130
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 154
static DoesntContain
doesntContain(array|Arrayable|UnitEnum|string $values)
Get a doesnt_contain rule builder instance.
at line 166
static RequiredIf
requiredIf(bool|Closure|null $callback)
Get a required_if rule builder instance.
at line 174
static RequiredUnless
requiredUnless(bool|Closure|null $callback)
Get a required_unless rule builder instance.
at line 182
static ExcludeIf
excludeIf(bool|Closure $callback)
Get a exclude_if rule builder instance.
at line 190
static ExcludeUnless
excludeUnless(bool|Closure $callback)
Get a exclude_unless rule builder instance.
at line 198
static ProhibitedIf
prohibitedIf(bool|Closure $callback)
Get a prohibited_if rule builder instance.
at line 206
static ProhibitedUnless
prohibitedUnless(bool|Closure $callback)
Get a prohibited_unless rule builder instance.
at line 214
static Date
date()
Get a date rule builder instance.
at line 222
static Date
dateTime()
Get a datetime rule builder instance.
at line 230
static Email
email()
Get an email rule builder instance.
at line 240
static Enum
enum(string $type)
Get an enum rule builder instance.
at line 248
static File
file()
Get a file rule builder instance.
at line 256
static ImageFile
imageFile(bool $allowSvg = false)
Get an image file rule builder instance.
at line 264
static Dimensions
dimensions(array $constraints = [])
Get a dimensions rule builder instance.
at line 272
static StringRule
string()
Get a string rule builder instance.
at line 280
static Numeric
numeric()
Get a numeric rule builder instance.
at line 290
static AnyOf
anyOf(array $rules)
Get an "any of" rule builder instance.
at line 298
static object
compile(string $attribute, mixed $rules, array|null $data = null)
Compile a set of rules for an attribute.
at line 329
static void
flushState()
Flush all static state.