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

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.

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.

void
__clone()

Clone the nested executable rule objects.

static void
macro(string $name, callable|object $macro)

Register a custom macro.

static void
mixin(object $mixin, bool $replace = true)

Mix another object into the class.

static bool
hasMacro(string $name)

Check if macro is registered.

static void
flushMacros()

Flush the existing macros.

static mixed
__callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

mixed
__call(string $method, array $parameters)

Dynamically handle calls to the class.

static Email|null
defaults(mixed $callback = null)

Set the default callback to be used for determining the email default rules.

static Email
default()

Get the default configuration of the email rule.

rfcCompliant(bool $strict = false)

Ensure that the email is an RFC compliant email address.

strict()

Ensure that the email is a strictly enforced RFC compliant email address.

validateMxRecord()

Ensure that the email address has a valid MX record.

preventSpoofing()

Ensure that the email address is not attempting to spoof another email address using invalid unicode characters.

withNativeValidation(bool $allowUnicode = false)

Ensure the email address is valid using PHP's native email validation functions.

rules(array|string $rules)

Specify additional validation rules that should be merged with the default rules during validation.

bool
passes(string $attribute, mixed $value)

Determine if the validation rule passes.

array
buildValidationRules()

Build the array of underlying validation rules based on the current state.

array|string
message()

Get the validation error message.

setValidator(Validator $validator)

Set the current validator.

setData(array $data)

Set the current data under validation.

static void
flushState()

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.

Parameters

mixed $value
callable|null $callback
callable|null $default

Return Value

mixed

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.

Parameters

mixed $value
callable|null $callback
callable|null $default

Return Value

mixed

in ClonesCustomRules at line 16
void __clone()

Clone the nested executable rule objects.

Return Value

void

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.

Parameters

string $name
callable|object $macro

Return Value

void

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.

Parameters

object $mixin
bool $replace

Return Value

void

Exceptions

ReflectionException

in Macroable at line 57
static bool hasMacro(string $name)

Check if macro is registered.

Parameters

string $name

Return Value

bool

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.

Return Value

void

in Macroable at line 78
static mixed __callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

in Macroable at line 103
mixed __call(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

at line 74
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.

Boot-only when setting. The default callback persists in a static property for the worker lifetime and is used by every Email::default() call across all coroutines.

Parameters

mixed $callback

Return Value

Email|null

at line 92
static Email default()

Get the default configuration of the email rule.

Return Value

Email

at line 112
Email rfcCompliant(bool $strict = false)

Ensure that the email is an RFC compliant email address.

Parameters

bool $strict

Return Value

Email

at line 126
Email strict()

Ensure that the email is a strictly enforced RFC compliant email address.

Return Value

Email

at line 136
Email validateMxRecord()

Ensure that the email address has a valid MX record.

Requires the PHP intl extension.

Return Value

Email

at line 146
Email preventSpoofing()

Ensure that the email address is not attempting to spoof another email address using invalid unicode characters.

Return Value

Email

at line 156
Email withNativeValidation(bool $allowUnicode = false)

Ensure the email address is valid using PHP's native email validation functions.

Parameters

bool $allowUnicode

Return Value

Email

at line 170
Email rules(array|string $rules)

Specify additional validation rules that should be merged with the default rules during validation.

Parameters

array|string $rules

Return Value

Email

at line 180
bool passes(string $attribute, mixed $value)

Determine if the validation rule passes.

Parameters

string $attribute
mixed $value

Return Value

bool

at line 207
protected array buildValidationRules()

Build the array of underlying validation rules based on the current state.

Return Value

array

at line 247
array|string message()

Get the validation error message.

Return Value

array|string

at line 255
ValidatorAwareRule setValidator(Validator $validator)

Set the current validator.

Parameters

Validator $validator

Return Value

ValidatorAwareRule

at line 265
DataAwareRule setData(array $data)

Set the current data under validation.

Parameters

array $data

Return Value

DataAwareRule

at line 275
static void flushState()

Flush all static state.

Return Value

void