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
c7aa31de
Commit
c7aa31de
authored
Jul 31, 2015
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(mvc) add basic validation to CSVListField type
parent
fb2f4c3f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
2 deletions
+25
-2
CSVListField.php
.../mvc/app/models/OPNsense/Base/FieldTypes/CSVListField.php
+25
-2
No files found.
src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/CSVListField.php
View file @
c7aa31de
...
...
@@ -54,6 +54,20 @@ class CSVListField extends BaseField
*/
private
$selectOptions
=
array
();
/**
* @var string basic regex validation to use for the complete field
*/
protected
$internalMask
=
'/^([\t\n\v\f\r 0-9a-zA-Z.,_\x{00A0}-\x{FFFF}])*/u'
;
/**
* set validation mask
* @param string $value regexp validation mask
*/
public
function
setMask
(
$value
)
{
$this
->
internalMask
=
$value
;
}
/**
* retrieve data including selection options (from setSelectOptions)
* @return array
...
...
@@ -107,10 +121,19 @@ class CSVListField extends BaseField
}
/**
* @return array returns
validators
* @return array returns
regex validator
*/
public
function
getValidators
()
{
return
array
()
;
if
(
$this
->
internalValidationMessage
==
null
)
{
$msg
=
"list validation error"
;
}
else
{
$msg
=
$this
->
internalValidationMessage
;
}
if
((
$this
->
internalIsRequired
||
$this
->
internalValue
!=
null
)
&&
$this
->
internalMask
!=
null
)
{
return
array
(
new
Regex
(
array
(
'message'
=>
$msg
,
'pattern'
=>
trim
(
$this
->
internalMask
))));
}
else
{
return
array
();
}
}
}
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