Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F120835516
FileName.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
FileName.php
View Options
<?php
namespace
App\Rules
;
use
Illuminate\Contracts\Validation\Rule
;
class
FileName
implements
Rule
{
private
$message
;
/**
* Determine if the validation rule passes.
*
* @param string $attribute Attribute name
* @param mixed $name The value to validate
*
* @return bool
*/
public
function
passes
(
$attribute
,
$name
):
bool
{
if
(
empty
(
$name
)
||
!
is_string
(
$name
))
{
$this
->
message
=
\trans
(
'validation.file-name-invalid'
);
return
false
;
}
// Check the max length, according to the database column length
if
(
strlen
(
$name
)
>
512
)
{
$this
->
message
=
\trans
(
'validation.max.string'
,
[
'max'
=>
512
]);
return
false
;
}
// Non-allowed characters
if
(
preg_match
(
'|[
\x
00-
\x
1F
\/
*"
\x
7F]|'
,
$name
))
{
$this
->
message
=
\trans
(
'validation.file-name-invalid'
);
return
false
;
}
// Leading/trailing spaces, or all spaces
if
(
preg_match
(
'|^
\s
+$|'
,
$name
)
||
preg_match
(
'|^
\s
+|'
,
$name
)
||
preg_match
(
'|
\s
+$|'
,
$name
))
{
$this
->
message
=
\trans
(
'validation.file-name-invalid'
);
return
false
;
}
// FIXME: Should we require a dot?
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, 1:19 PM (3 d, 7 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18829704
Default Alt Text
FileName.php (1 KB)
Attached To
Mode
rK kolab
Attached
Detach File
Event Timeline