Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F555635
AlmanacNames.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
AlmanacNames.php
View Options
<?php
final
class
AlmanacNames
extends
Phobject
{
public
static
function
validateName
(
$name
)
{
if
(
strlen
(
$name
)
<
3
)
{
throw
new
Exception
(
pht
(
'Almanac service, device, property, network and namespace names '
.
'must be at least 3 characters long.'
));
}
if
(
strlen
(
$name
)
>
100
)
{
throw
new
Exception
(
pht
(
'Almanac service, device, property, network and namespace names '
.
'may not be more than 100 characters long.'
));
}
if
(!
preg_match
(
'/^[a-z0-9.-]+
\z
/'
,
$name
))
{
throw
new
Exception
(
pht
(
'Almanac service, device, property, network and namespace names '
.
'may only contain lowercase letters, numbers, hyphens, and '
.
'periods.'
));
}
if
(
preg_match
(
'/(^|
\\
.)
\d
+(
\z
|
\\
.)/'
,
$name
))
{
throw
new
Exception
(
pht
(
'Almanac service, device, network, property and namespace names '
.
'may not have any segments containing only digits.'
));
}
if
(
preg_match
(
'/
\.\.
/'
,
$name
))
{
throw
new
Exception
(
pht
(
'Almanac service, device, property, network and namespace names '
.
'may not contain multiple consecutive periods.'
));
}
if
(
preg_match
(
'/
\\
.-|-
\\
./'
,
$name
))
{
throw
new
Exception
(
pht
(
'Almanac service, device, property, network and namespace names '
.
'may not contain hyphens adjacent to periods.'
));
}
if
(
preg_match
(
'/--/'
,
$name
))
{
throw
new
Exception
(
pht
(
'Almanac service, device, property, network and namespace names '
.
'may not contain multiple consecutive hyphens.'
));
}
if
(!
preg_match
(
'/^[a-z0-9].*[a-z0-9]
\z
/'
,
$name
))
{
throw
new
Exception
(
pht
(
'Almanac service, device, property, network and namespace names '
.
'must begin and end with a letter or number.'
));
}
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, May 12, 6:43 PM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
107408
Default Alt Text
AlmanacNames.php (1 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment