mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-13 16:14:40 +00:00
MVC - add a field type for descriptions and uniform description uses in core modules.
This commit is contained in:
parent
135a663e33
commit
84e43caf2d
1
plist
1
plist
@ -526,6 +526,7 @@
|
||||
/usr/local/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/ConfigdActionsField.php
|
||||
/usr/local/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/ContainerField.php
|
||||
/usr/local/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/CountryField.php
|
||||
/usr/local/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/DescriptionField.php
|
||||
/usr/local/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/EmailField.php
|
||||
/usr/local/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/HostnameField.php
|
||||
/usr/local/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/IntegerField.php
|
||||
|
||||
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2023 Deciso B.V.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
namespace OPNsense\Base\FieldTypes;
|
||||
|
||||
use OPNsense\Base\Validators\CallbackValidator;
|
||||
|
||||
/**
|
||||
* Class DescriptionField
|
||||
*/
|
||||
class DescriptionField extends TextField
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function defaultValidationMessage()
|
||||
{
|
||||
return gettext('Description should be a string between 1 and 255 characters.');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getValidators()
|
||||
{
|
||||
$validators = parent::getValidators();
|
||||
if ($this->internalValue != null) {
|
||||
$validators[] = new CallbackValidator(["callback" => function ($data) {
|
||||
if (!preg_match('/^(.){1,255}$/', $data)) {
|
||||
return [$this->getValidationMessage()];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
]);
|
||||
}
|
||||
return $validators;
|
||||
}
|
||||
}
|
||||
@ -89,10 +89,8 @@
|
||||
</Model>
|
||||
<ValidationMessage>Related template not found</ValidationMessage>
|
||||
</template>
|
||||
<description type="TextField">
|
||||
<description type="DescriptionField">
|
||||
<Required>Y</Required>
|
||||
<Mask>/^([\t\n\v\f\r 0-9a-zA-Z.,_\x{00A0}-\x{FFFF}]){1,255}$/u</Mask>
|
||||
<ValidationMessage>Description should be a string between 1 and 255 characters</ValidationMessage>
|
||||
</description>
|
||||
</zone>
|
||||
</zones>
|
||||
|
||||
@ -60,9 +60,7 @@
|
||||
<Mask>/^(.){1,255}$/</Mask>
|
||||
<ValidationMessage>Input too long.</ValidationMessage>
|
||||
</parameters>
|
||||
<description type="TextField">
|
||||
<Mask>/^([\t\n\v\f\r 0-9a-zA-Z.,_\x{00A0}-\x{FFFF}]){1,255}$/u</Mask>
|
||||
<ValidationMessage>Enter a description.</ValidationMessage>
|
||||
<description type="DescriptionField">
|
||||
<Required>Y</Required>
|
||||
</description>
|
||||
</job>
|
||||
|
||||
@ -9,10 +9,7 @@
|
||||
<AllowDynamic>Y</AllowDynamic>
|
||||
<Multiple>Y</Multiple>
|
||||
</interface>
|
||||
<description type="TextField">
|
||||
<Mask>/^(.){1,255}$/u</Mask>
|
||||
<ValidationMessage>Description should be a string between 1 and 255 characters</ValidationMessage>
|
||||
</description>
|
||||
<description type="DescriptionField"/>
|
||||
<promiscuous type="BooleanField">
|
||||
<Default>0</Default>
|
||||
<Required>Y</Required>
|
||||
|
||||
@ -25,10 +25,7 @@
|
||||
<MaximumValue>65535</MaximumValue>
|
||||
</packetsize>
|
||||
<disable_frag type="BooleanField"/>
|
||||
<description type="TextField">
|
||||
<Mask>/^(.){1,255}$/u</Mask>
|
||||
<ValidationMessage>Description should be a string between 1 and 255 characters</ValidationMessage>
|
||||
</description>
|
||||
<description type="DescriptionField"/>
|
||||
</settings>
|
||||
</items>
|
||||
</model>
|
||||
|
||||
@ -78,10 +78,7 @@
|
||||
<Multiple>Y</Multiple>
|
||||
<ValidationMessage>Related category not found.</ValidationMessage>
|
||||
</categories>
|
||||
<description type="TextField">
|
||||
<Mask>/^(.){1,255}$/u</Mask>
|
||||
<ValidationMessage>Description should be a string between 1 and 255 characters</ValidationMessage>
|
||||
</description>
|
||||
<description type="DescriptionField"/>
|
||||
</alias>
|
||||
</aliases>
|
||||
</items>
|
||||
|
||||
@ -107,10 +107,7 @@
|
||||
<Multiple>Y</Multiple>
|
||||
<ValidationMessage>Related category not found.</ValidationMessage>
|
||||
</categories>
|
||||
<description type="TextField">
|
||||
<Mask>/^([\t\n\v\f\r 0-9a-zA-Z.\-,_\x{00A0}-\x{FFFF}]){0,255}$/u</Mask>
|
||||
<ValidationMessage>Description should be a string between 1 and 255 characters</ValidationMessage>
|
||||
</description>
|
||||
<description type="DescriptionField"/>
|
||||
</rule>
|
||||
</rules>
|
||||
<snatrules>
|
||||
@ -198,10 +195,7 @@
|
||||
<Multiple>Y</Multiple>
|
||||
<ValidationMessage>Related category not found.</ValidationMessage>
|
||||
</categories>
|
||||
<description type="TextField">
|
||||
<Mask>/^([\t\n\v\f\r 0-9a-zA-Z.\-,_\x{00A0}-\x{FFFF}]){0,255}$/u</Mask>
|
||||
<ValidationMessage>Description should be a string between 1 and 255 characters</ValidationMessage>
|
||||
</description>
|
||||
<description type="DescriptionField"/>
|
||||
</rule>
|
||||
</snatrules>
|
||||
<npt>
|
||||
@ -250,10 +244,7 @@
|
||||
<Multiple>Y</Multiple>
|
||||
<ValidationMessage>Related category not found.</ValidationMessage>
|
||||
</categories>
|
||||
<description type="TextField">
|
||||
<Mask>/^([\t\n\v\f\r 0-9a-zA-Z.\-,_\x{00A0}-\x{FFFF}]){0,255}$/u</Mask>
|
||||
<ValidationMessage>Description should be a string between 1 and 255 characters</ValidationMessage>
|
||||
</description>
|
||||
<description type="DescriptionField"/>
|
||||
</rule>
|
||||
</npt>
|
||||
</items>
|
||||
|
||||
@ -25,10 +25,7 @@
|
||||
<Required>Y</Required>
|
||||
<Default>0</Default>
|
||||
</sequence>
|
||||
<descr type="TextField">
|
||||
<Mask>/^([\t\n\v\f\r 0-9a-zA-Z.\-,_\x{00A0}-\x{FFFF}]){0,255}$/u</Mask>
|
||||
<ValidationMessage>Description should be a string between 1 and 255 characters</ValidationMessage>
|
||||
</descr>
|
||||
<descr type="DescriptionField"/>
|
||||
</ifgroupentry>
|
||||
</items>
|
||||
</model>
|
||||
|
||||
@ -70,10 +70,7 @@
|
||||
<disable>Disable</disable>
|
||||
</OptionValues>
|
||||
</new_action>
|
||||
<description type="TextField">
|
||||
<Mask>/^(.){1,255}$/u</Mask>
|
||||
<ValidationMessage>Description should be a string between 1 and 255 characters</ValidationMessage>
|
||||
</description>
|
||||
<description type="DescriptionField"/>
|
||||
</policy>
|
||||
</policies>
|
||||
<userDefinedRules>
|
||||
@ -89,10 +86,8 @@
|
||||
<Mask>/^([0-9a-fA-F:]){59,59}$/u</Mask>
|
||||
<ValidationMessage>A SSL fingerprint should be a 59 character long hex value.</ValidationMessage>
|
||||
</fingerprint>
|
||||
<description type="TextField">
|
||||
<description type="DescriptionField">
|
||||
<Required>Y</Required>
|
||||
<Mask>/^([\t\n\v\f\r 0-9a-zA-Z.\-,_\x{00A0}-\x{FFFF}]){1,255}$/u</Mask>
|
||||
<ValidationMessage>Description should be a string between 1 and 255 characters.</ValidationMessage>
|
||||
</description>
|
||||
<action type="OptionField">
|
||||
<Required>Y</Required>
|
||||
|
||||
@ -98,7 +98,7 @@
|
||||
<MinimumValue>0</MinimumValue>
|
||||
<MaximumValue>1000</MaximumValue>
|
||||
</keyingtries>
|
||||
<description type="TextField">
|
||||
<description type="DescriptionField">
|
||||
<Required>Y</Required>
|
||||
</description>
|
||||
</Connection>
|
||||
@ -157,7 +157,7 @@
|
||||
</Model>
|
||||
<Multiple>Y</Multiple>
|
||||
</pubkeys>
|
||||
<description type="TextField"/>
|
||||
<description type="DescriptionField"/>
|
||||
</local>
|
||||
</locals>
|
||||
<remotes>
|
||||
@ -218,7 +218,7 @@
|
||||
<Multiple>Y</Multiple>
|
||||
</pubkeys>
|
||||
<!-- XXX add cacert field + logic in ipsec_write_cas -->
|
||||
<description type="TextField"/>
|
||||
<description type="DescriptionField"/>
|
||||
</remote>
|
||||
</remotes>
|
||||
<children>
|
||||
@ -309,7 +309,7 @@
|
||||
<MaximumValue>500000</MaximumValue>
|
||||
<Required>Y</Required>
|
||||
</rekey_time>
|
||||
<description type="TextField"/>
|
||||
<description type="DescriptionField"/>
|
||||
</child>
|
||||
</children>
|
||||
<Pools>
|
||||
@ -394,7 +394,7 @@
|
||||
<WildcardEnabled>N</WildcardEnabled>
|
||||
<ValidationMessage>Please specify a valid address.</ValidationMessage>
|
||||
</tunnel_remote2>
|
||||
<description type="TextField"/>
|
||||
<description type="DescriptionField"/>
|
||||
</VTI>
|
||||
</VTIs>
|
||||
<SPDs>
|
||||
@ -432,7 +432,7 @@
|
||||
<destination type="NetworkField">
|
||||
<WildcardEnabled>N</WildcardEnabled>
|
||||
</destination>
|
||||
<description type="TextField"/>
|
||||
<description type="DescriptionField"/>
|
||||
</SPD>
|
||||
</SPDs>
|
||||
</items>
|
||||
|
||||
@ -61,10 +61,7 @@
|
||||
<MinimumValue>576</MinimumValue>
|
||||
<MaximumValue>65535</MaximumValue>
|
||||
</mtu>
|
||||
<descr type="TextField">
|
||||
<Mask>/^([\t\n\v\f\r 0-9a-zA-Z.\-,_\x{00A0}-\x{FFFF}]){1,255}$/u</Mask>
|
||||
<ValidationMessage>Description should be a string between 1 and 255 characters</ValidationMessage>
|
||||
</descr>
|
||||
<descr type="DescriptionField"/>
|
||||
</lagg>
|
||||
</items>
|
||||
</model>
|
||||
|
||||
@ -7,10 +7,8 @@
|
||||
<deviceId type="AutoNumberField">
|
||||
<Required>Y</Required>
|
||||
</deviceId>
|
||||
<description type="TextField">
|
||||
<description type="DescriptionField">
|
||||
<Required>Y</Required>
|
||||
<Mask>/^([\t\n\v\f\r 0-9a-zA-Z.\-,_\x{00A0}-\x{FFFF}]){1,255}$/u</Mask>
|
||||
<ValidationMessage>Description should be a string between 1 and 255 characters</ValidationMessage>
|
||||
</description>
|
||||
</loopback>
|
||||
</items>
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
<Required>Y</Required>
|
||||
<NetMaskAllowed>N</NetMaskAllowed>
|
||||
</ipaddress>
|
||||
<descr type="TextField"/>
|
||||
<descr type="DescriptionField"/>
|
||||
</neighbor>
|
||||
</items>
|
||||
</model>
|
||||
|
||||
@ -54,7 +54,7 @@
|
||||
<MaximumValue>254</MaximumValue>
|
||||
<ValidationMessage>Invalid skew value, acceptable values are 0 to 255.</ValidationMessage>
|
||||
</advskew>
|
||||
<descr type="TextField"/>
|
||||
<descr type="DescriptionField"/>
|
||||
</vip>
|
||||
</items>
|
||||
</model>
|
||||
|
||||
@ -47,7 +47,7 @@
|
||||
<opt2 value="802.1ad">802.1ad</opt2>
|
||||
</OptionValues>
|
||||
</proto>
|
||||
<descr type="TextField"/>
|
||||
<descr type="DescriptionField"/>
|
||||
<vlanif type="TextField">
|
||||
<Required>Y</Required>
|
||||
<Constraints>
|
||||
|
||||
@ -88,8 +88,7 @@
|
||||
</hw_address>
|
||||
<hostname type="HostnameField">
|
||||
</hostname>
|
||||
<description type="TextField">
|
||||
</description>
|
||||
<description type="DescriptionField"/>
|
||||
</reservation>
|
||||
</reservations>
|
||||
<ha_peers>
|
||||
|
||||
@ -155,10 +155,7 @@
|
||||
<MaximumValue>86400</MaximumValue>
|
||||
<ValidationMessage>Reminder needs to be an integer value between 0 and 86400</ValidationMessage>
|
||||
</reminder>
|
||||
<description type="TextField">
|
||||
<Mask>/^.{1,255}$/u</Mask>
|
||||
<ValidationMessage>Enter a description.</ValidationMessage>
|
||||
</description>
|
||||
<description type="DescriptionField"/>
|
||||
</alert>
|
||||
<service type="ArrayField">
|
||||
<enabled type="BooleanField">
|
||||
@ -176,7 +173,7 @@
|
||||
</check001>
|
||||
</Constraints>
|
||||
</name>
|
||||
<description type="TextField"/>
|
||||
<description type="DescriptionField"/>
|
||||
<type type="OptionField">
|
||||
<Required>Y</Required>
|
||||
<OptionValues>
|
||||
|
||||
@ -79,7 +79,7 @@
|
||||
<FieldSeparator>,</FieldSeparator>
|
||||
<asList>Y</asList>
|
||||
</wins_servers>
|
||||
<description type="TextField"/>
|
||||
<description type="DescriptionField"/>
|
||||
</Overwrite>
|
||||
</Overwrites>
|
||||
<Instances>
|
||||
@ -343,7 +343,7 @@
|
||||
<type>carp</type>
|
||||
<key>mvc</key>
|
||||
</carp_depend_on>
|
||||
<description type="TextField"/>
|
||||
<description type="DescriptionField"/>
|
||||
</Instance>
|
||||
</Instances>
|
||||
<StaticKeys>
|
||||
@ -360,7 +360,7 @@
|
||||
<Required>Y</Required>
|
||||
<ValidationMessage>A key is required, generate one with the button</ValidationMessage>
|
||||
</key>
|
||||
<description type="TextField"/>
|
||||
<description type="DescriptionField"/>
|
||||
</StaticKey>
|
||||
</StaticKeys>
|
||||
</items>
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
<ConfigdPopulateTTL>20</ConfigdPopulateTTL>
|
||||
<ValidationMessage>Specify a valid gateway from the list matching the networks ip protocol.</ValidationMessage>
|
||||
</gateway>
|
||||
<descr type="TextField"/>
|
||||
<descr type="DescriptionField"/>
|
||||
<disabled type="BooleanField">
|
||||
<Default>0</Default>
|
||||
<Required>Y</Required>
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
</check001>
|
||||
</Constraints>
|
||||
</name>
|
||||
<descr type="TextField"/>
|
||||
<descr type="DescriptionField"/>
|
||||
<interface type="InterfaceField">
|
||||
<Required>Y</Required>
|
||||
<Default>wan</Default>
|
||||
|
||||
@ -89,7 +89,7 @@
|
||||
<Default>0</Default>
|
||||
<Required>Y</Required>
|
||||
</rfc5424>
|
||||
<description type="TextField"/>
|
||||
<description type="DescriptionField"/>
|
||||
</destination>
|
||||
</destinations>
|
||||
</items>
|
||||
|
||||
@ -115,10 +115,8 @@
|
||||
<MaximumValue>3000</MaximumValue>
|
||||
<ValidationMessage>Please choose a value between 1 and 3000</ValidationMessage>
|
||||
</delay>
|
||||
<description type="TextField">
|
||||
<description type="DescriptionField">
|
||||
<Required>Y</Required>
|
||||
<Mask>/^([\t\n\v\f\r 0-9a-zA-Z.\-,_\x{00A0}-\x{FFFF}]){1,255}$/u</Mask>
|
||||
<ValidationMessage>Description should be a string between 1 and 255 characters</ValidationMessage>
|
||||
</description>
|
||||
</pipe>
|
||||
</pipes>
|
||||
@ -200,10 +198,8 @@
|
||||
</check001>
|
||||
</Constraints>
|
||||
</pie_enable>
|
||||
<description type="TextField">
|
||||
<description type="DescriptionField">
|
||||
<Required>Y</Required>
|
||||
<Mask>/^([\t\n\v\f\r 0-9a-zA-Z.\-,_\x{00A0}-\x{FFFF}]){1,255}$/u</Mask>
|
||||
<ValidationMessage>Description should be a string between 1 and 255 characters</ValidationMessage>
|
||||
</description>
|
||||
<origin type="TextField">
|
||||
<Mask>/^([a-z,A-Z,1-9]){0,30}$/</Mask>
|
||||
@ -349,9 +345,7 @@
|
||||
<ValidationMessage>Related pipe or queue not found</ValidationMessage>
|
||||
<Required>Y</Required>
|
||||
</target>
|
||||
<description type="TextField">
|
||||
<Mask>/^([\t\n\v\f\r 0-9a-zA-Z.\-,_\x{00A0}-\x{FFFF}]){0,255}$/u</Mask>
|
||||
</description>
|
||||
<description type="DescriptionField"/>
|
||||
<origin type="TextField">
|
||||
<Mask>/^([a-z,A-Z,1-9]){0,30}$/</Mask>
|
||||
<ValidationMessage>origin should be regular text of max 30 characters</ValidationMessage>
|
||||
|
||||
@ -164,10 +164,7 @@
|
||||
<NetMaskRequired>Y</NetMaskRequired>
|
||||
<asList>Y</asList>
|
||||
</networks>
|
||||
<description type="TextField">
|
||||
<Mask>/^(.){1,255}$/u</Mask>
|
||||
<ValidationMessage>Description should be a string between 1 and 255 characters</ValidationMessage>
|
||||
</description>
|
||||
<description type="DescriptionField"/>
|
||||
</acl>
|
||||
</acls>
|
||||
<dnsbl>
|
||||
@ -332,10 +329,7 @@
|
||||
</check002>
|
||||
</Constraints>
|
||||
</server>
|
||||
<description type="TextField">
|
||||
<Mask>/^(.){1,255}$/u</Mask>
|
||||
<ValidationMessage>Description should be a string between 1 and 255 characters</ValidationMessage>
|
||||
</description>
|
||||
<description type="DescriptionField"/>
|
||||
</host>
|
||||
</hosts>
|
||||
<aliases>
|
||||
@ -378,10 +372,7 @@
|
||||
<Mask>/^(?:(?:[a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])\.)*(?:[a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])$/i</Mask>
|
||||
<ValidationMessage>A valid domain must be specified.</ValidationMessage>
|
||||
</domain>
|
||||
<description type="TextField">
|
||||
<Mask>/^(.){1,255}$/u</Mask>
|
||||
<ValidationMessage>Description should be a string between 1 and 255 characters</ValidationMessage>
|
||||
</description>
|
||||
<description type="DescriptionField"/>
|
||||
</alias>
|
||||
</aliases>
|
||||
<domains>
|
||||
@ -402,10 +393,7 @@
|
||||
<Default>0</Default>
|
||||
<Required>Y</Required>
|
||||
</forward_tcp_upstream>
|
||||
<description type="TextField">
|
||||
<Mask>/^(.){1,255}$/u</Mask>
|
||||
<ValidationMessage>Description should be a string between 1 and 255 characters</ValidationMessage>
|
||||
</description>
|
||||
<description type="DescriptionField"/>
|
||||
</domain>
|
||||
</domains>
|
||||
</items>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user