Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F120824638
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
{
private
$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
*
* @return bool
*/
public
function
passes
(
$attribute
,
$email
):
bool
{
$v
=
Validator
::
make
([
'email'
=>
$email
],
[
'email'
=>
'required|email'
]);
if
(
$v
->
fails
())
{
$this
->
message
=
\trans
(
'validation.emailinvalid'
);
return
false
;
}
list
(
$local
,
$domain
)
=
explode
(
'@'
,
$email
);
// don't allow @localhost and other no-fqdn
if
(
strpos
(
$domain
,
'.'
)
===
false
)
{
$this
->
message
=
\trans
(
'validation.emailinvalid'
);
return
false
;
}
return
true
;
}
/**
* Get the validation error message.
*
* @return string
*/
public
function
message
():
?
string
{
return
$this
->
message
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Apr 24, 10:25 AM (1 d, 8 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
83/dc/51af067b6bc91e8b68e3179d749a
Default Alt Text
ExternalEmail.php (1 KB)
Attached To
Mode
rK kolab
Attached
Detach File
Event Timeline