Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F120824166
ExternalEmail.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
ExternalEmail.php
View Options
<?php
namespace
App\Rules
;
use
Illuminate\Contracts\Validation\Rule
;
use
Illuminate\Support\Facades\Validator
;
class
ExternalEmail
implements
Rule
{
protected
$message
;
/**
* Determine if the validation rule passes.
*
* Email address validation with some more strict rules
* than the default Laravel's 'email' rule
*
* @param string $attribute Attribute name
* @param mixed $email Email address input
*/
public
function
passes
(
$attribute
,
$email
):
bool
{
$v
=
Validator
::
make
([
'email'
=>
$email
],
[
'email'
=>
'required|email:strict'
]);
if
(
$v
->
fails
())
{
$this
->
message
=
\trans
(
'validation.emailinvalid'
);
return
false
;
}
[
$local
,
$domain
]
=
explode
(
'@'
,
$email
);
// don't allow @localhost and other no-fqdn
if
(!
str_contains
(
$domain
,
'.'
))
{
$this
->
message
=
\trans
(
'validation.emailinvalid'
);
return
false
;
}
// don't allow IPv6 addresses in the domain part
if
(
str_contains
(
$domain
,
':'
))
{
$this
->
message
=
\trans
(
'validation.emailinvalid'
);
return
false
;
}
// don't allow IPv4 addresses in the domain part
if
(
preg_match
(
'/^[0-9.]+$/'
,
$domain
))
{
$this
->
message
=
\trans
(
'validation.emailinvalid'
);
return
false
;
}
return
true
;
}
/**
* Get the validation error message.
*/
public
function
message
():
?
string
{
return
$this
->
message
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Apr 24, 10:18 AM (1 h, 20 m ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18741501
Default Alt Text
ExternalEmail.php (1 KB)
Attached To
Mode
rK kolab
Attached
Detach File
Event Timeline