Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
c2b3c674
Commit
c2b3c674
authored
Feb 23, 2016
by
Charlie Root
Committed by
Franco Fichtner
Feb 25, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add NetMaskRequired option to NetworkField and NetworkValidator
(cherry picked from commit
7f3e9791
)
parent
de90325f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
1 deletion
+22
-1
NetworkField.php
.../mvc/app/models/OPNsense/Base/FieldTypes/NetworkField.php
+18
-1
NetworkValidator.php
.../app/models/OPNsense/Base/Validators/NetworkValidator.php
+4
-0
No files found.
src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/NetworkField.php
View file @
c2b3c674
...
...
@@ -47,6 +47,11 @@ class NetworkField extends BaseField
*/
protected
$internalValidationMessage
=
"please specify a valid network segment or address (IPv4/IPv6) "
;
/**
* @var bool marks if net mask is required
*/
protected
$internalNetMaskRequired
=
false
;
/**
* always lowercase / trim networks
* @param string $value
...
...
@@ -56,6 +61,15 @@ class NetworkField extends BaseField
parent
::
setValue
(
trim
(
strtolower
(
$value
)));
}
/**
* setter for net mask required
* @param integer $value
*/
public
function
setNetMaskRequired
(
$value
)
{
$this
->
internalNetMaskRequired
=
(
trim
(
strtolower
(
$value
))
==
'y'
||
intval
(
$value
)
==
1
);
}
/**
* retrieve field validators for this field type
* @return array returns Text/regex validator
...
...
@@ -66,7 +80,10 @@ class NetworkField extends BaseField
if
(
$this
->
internalValue
!=
null
)
{
if
(
$this
->
internalValue
!=
"any"
)
{
// accept any as target
$validators
[]
=
new
NetworkValidator
(
array
(
'message'
=>
$this
->
internalValidationMessage
));
$validators
[]
=
new
NetworkValidator
(
array
(
'message'
=>
$this
->
internalValidationMessage
,
'netMaskRequired'
=>
$this
->
internalNetMaskRequired
));
}
}
return
$validators
;
...
...
src/opnsense/mvc/app/models/OPNsense/Base/Validators/NetworkValidator.php
View file @
c2b3c674
...
...
@@ -103,6 +103,10 @@ class NetworkValidator extends Validator implements ValidatorInterface
}
}
}
else
if
(
$this
->
getOption
(
'netMaskRequired'
)
===
true
)
{
$result
=
false
;
}
if
(
filter_var
(
$value
,
FILTER_VALIDATE_IP
,
$filterOpt
)
===
false
)
{
$result
=
false
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment