CkEmailException
What CkEmail throws — only when asked.
Raised by any CkEmail method called with
throwIfInvalid: true when neither the value nor the fallback can be used. Never
thrown otherwise: by default those methods answer '', false or a mask's
placeholder instead. Final, and derived from CkException.
The message names the method, shows the value with its type, says what it was meant to be and why it failed:
CkEmail.Address: cannot use "bob@" (String) as an email address — not a valid address.
Properties
Every property is public readonly.
| Property | Type | What it holds |
|---|---|---|
Expected |
string |
What the value was meant to be — 'an email address'. |
Input |
mixed |
From CkException: the value that failed, untouched. |
Reason |
string |
From CkException: why, in a few words. |
Quick look
use SafeCoder\CommonKit\CkEmail;
use SafeCoder\CommonKit\Exceptions\CkEmailException;
try {
CkEmail::Address(
input: 'bob@',
throwIfInvalid: true
);
} catch (CkEmailException $error) {
echo $error->Reason; // -> 'not a valid address'
echo $error->Expected; // -> 'an email address'
}