class Email implements Rule, DataAwareRule, ValidatorAwareRule
Traits
Properties
| static protected array | $macros | The registered string macros. |
from Macroable |
| bool | $validateMxRecord | ||
| bool | $preventSpoofing | ||
| bool | $nativeValidation | ||
| bool | $nativeValidationWithUnicodeAllowed | ||
| bool | $rfcCompliant | ||
| bool | $strictRfcCompliant | ||
| protected Validator|null | $validator | The validator performing the validation. |
|
| protected array | $data | The data under validation. |
|
| protected array | $customRules | An array of custom rules that will be merged into the validation rules. |
|
| protected array | $messages | The error message after validation, if any. |
|
| static null|array|callable|string | $defaultCallback | The callback that will generate the "default" version of the email rule. |
Methods
Apply the callback if the given "value" is (or resolves to) truthy.
Apply the callback if the given "value" is (or resolves to) falsy.
Mix another object into the class.
Dynamically handle calls to the class.
Dynamically handle calls to the class.
Set the default callback to be used for determining the email default rules.
Ensure that the email is an RFC compliant email address.
Check the email domain's MX records, with A or AAAA records as a fallback.
Ensure that the email address is not attempting to spoof another email address using invalid unicode characters.
Ensure the email address is valid using PHP's native email validation functions.
Specify additional validation rules that should be merged with the default rules during validation.
Determine if the validation rule passes.
Build the array of underlying validation rules based on the current state.
Get the validation error message.
Set the current data under validation.
Flush all static state.
Details
in
Conditionable at line 23
mixed
when(mixed $value = null, callable|null $callback = null, callable|null $default = null)
Apply the callback if the given "value" is (or resolves to) truthy.
in
Conditionable at line 56
mixed
unless(mixed $value = null, callable|null $callback = null, callable|null $default = null)
Apply the callback if the given "value" is (or resolves to) falsy.
in
ClonesCustomRules at line 15
void
__clone()
Clone the nested executable rule objects.
in
Macroable at line 30
static void
macro(string $name, callable|object $macro)
Register a custom macro.
Macros persist in a static property for the worker lifetime and apply to every subsequent call on the macroable class.
in
Macroable at line 44
static void
mixin(object $mixin, bool $replace = true)
Mix another object into the class.
Delegates to macro() for each method; registered macros persist in a static property for the worker lifetime.
in
Macroable at line 61
static bool
hasMacro(string $name)
Check if macro is registered.
in
Macroable at line 72
static void
flushMacros()
Flush the existing macros.
Clears worker-wide macros; concurrent coroutines may resolve different methods depending on timing.
in
Macroable at line 83
static mixed
__callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
in
Macroable at line 108
mixed
__call(string $method, array $parameters)
Dynamically handle calls to the class.
at line 78
static Email|null
defaults(mixed $callback = null)
Set the default callback to be used for determining the email default rules.
If no arguments are passed, the default email rule configuration will be returned.
A given callback persists in a static property for the worker lifetime and is used by every Email::default() call across all coroutines.
at line 97
static Email
default()
Get the default configuration of the email rule.
at line 119
Email
rfcCompliant(bool $strict = false)
Ensure that the email is an RFC compliant email address.
at line 135
Email
strict()
Ensure that the email is a strictly enforced RFC compliant email address.
at line 147
Email
validateMxRecord()
Check the email domain's MX records, with A or AAAA records as a fallback.
Requires the PHP intl extension.
at line 159
Email
preventSpoofing()
Ensure that the email address is not attempting to spoof another email address using invalid unicode characters.
at line 171
Email
withNativeValidation(bool $allowUnicode = false)
Ensure the email address is valid using PHP's native email validation functions.
at line 187
Email
rules(array|string $rules)
Specify additional validation rules that should be merged with the default rules during validation.
at line 197
bool
passes(string $attribute, mixed $value)
Determine if the validation rule passes.
at line 220
protected array
buildValidationRules()
Build the array of underlying validation rules based on the current state.
at line 260
array|string
message()
Get the validation error message.
at line 270
ValidatorAwareRule
setValidator(Validator $validator)
Set the current validator.
at line 282
DataAwareRule
setData(array $data)
Set the current data under validation.
at line 292
static void
flushState()
Flush all static state.