OPNsense comes with a collection of standard field types, which can be used to perform standard field type validations.
These field types can be found in `/usr/local/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/ <https://github.com/opnsense/core/tree/master/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes>`__
@ -8,6 +8,7 @@ and usually decent from the `BaseField` type.
This paragraph aims to provide an overview of the types included by default and their use.
..Tip::
When using lists, the :code:`Multiple` (Y/N) keyword defines if there may be more than one item selected at a time.
@ -16,6 +17,7 @@ This paragraph aims to provide an overview of the types included by default and
The xml keyword :code:`Required` can be used to mark a field as being required.
ArrayField
------------------------------------
@ -33,11 +35,32 @@ AuthGroupField
Returns and validates system (user) groups (found in :menuselection:`System --> Access --> Groups`)
..csv-table:: AuthGroupField
:header:"Parameter", "Options", "Purpose"
:widths:30, 20, 40
"default", ":code:`text`", "Default value for new attributes"
"Required", "Y,N", "Mark field as required"
"ValidationMessage", ":code:`text`", "Error message on validation failure"
"BlankDesc", ":code:`text`", "Set a label for the empty option"
"Multiple", "Y,N", "Allow to select multiple options"
AuthenticationServerField
------------------------------------
Select and validate authentication providers, maintained in :menuselection:`System --> Access --> Servers`.
..csv-table:: AuthenticationServerField
:header:"Parameter", "Options", "Purpose"
:widths:30, 20, 40
"default", ":code:`text`", "Default value for new attributes"
"Required", "Y,N", "Mark field as required"
"ValidationMessage", ":code:`text`", "Error message on validation failure"
"BlankDesc", ":code:`text`", "Set a label for the empty option"
"Multiple", "Y,N", "Allow to select multiple options"
"Filters", "Y,N", "A structure of regex filters per atribute to exclude certain options from the list"
AutoNumberField
------------------------------------
@ -45,26 +68,75 @@ AutoNumberField
An integer sequence, which automatically increments on every new item of the same type in the same level.
..csv-table:: AutoNumberField
:header:"Parameter", "Options", "Purpose"
:widths:30, 20, 40
"default", ":code:`text`", "Default value for new attributes"
"Required", "Y,N", "Mark field as required"
"ValidationMessage", ":code:`text`", "Error message on validation failure"
"MinimumValue", ":code:`int`", "Minimum number also starting point of the sequence"
"MaximumValue", ":code:`int`", "Maximum number"
Base64Field
------------------------------------
Validate if a given string contains a valid base64 decodable value.
..csv-table:: Base64Field
:header:"Parameter", "Options", "Purpose"
:widths:30, 20, 40
"default", ":code:`text`", "Default value for new attributes"
"Required", "Y,N", "Mark field as required"
"ValidationMessage", ":code:`text`", "Error message on validation failure"
"AddressFamily", ":code:`ipv4`, :code:`ipv6`", "Which address family to use, blank means ipv4+ipv6"
"FieldSeparator", ":code:`text`", "Separator character to use"
"WildcardEnabled", "Y,N", "Allow the use of the :code:`any` clause"
"AsList", "Y,N", "Field type should return list items"
NumericField
------------------------------------
Validate input to be of numeric type.
..csv-table:: NumericField
:header:"Parameter", "Options", "Purpose"
:widths:30, 20, 40
"default", ":code:`text`", "Default value for new attributes"
"Required", "Y,N", "Mark field as required"
"ValidationMessage", ":code:`text`", "Error message on validation failure"
"MinimumValue", ":code:`int`", "Minimum number"
"MaximumValue", ":code:`int`", "Maximum number"
OptionField
------------------------------------
Validate against a static list of options.
..csv-table:: OptionField
:header:"Parameter", "Options", "Purpose"
:widths:30, 20, 40
"default", ":code:`text`", "Default value for new attributes"
"Required", "Y,N", "Mark field as required"
"ValidationMessage", ":code:`text`", "Error message on validation failure"
"BlankDesc", ":code:`text`", "Set a label for the empty option"
"Multiple", "Y,N", "Allow to select multiple options"
"OptionValues", ":code:`xml`", "Xml structure containing keys and values, when keys should be numeric, the value tag is also supported :code:`<opt1 value='1'>option1</opt1>`"
PortField
------------------------------------
@ -220,29 +462,107 @@ Check if the input contains a valid portnumber or (optionally) predefined servic
:code:`EnableRanges` is set to :code:`Y`.
..csv-table:: PortField
:header:"Parameter", "Options", "Purpose"
:widths:30, 20, 40
"default", ":code:`text`", "Default value for new attributes"
"Required", "Y,N", "Mark field as required"
"ValidationMessage", ":code:`text`", "Error message on validation failure"
"BlankDesc", ":code:`text`", "Set a label for the empty option"
"Multiple", "Y,N", "Allow to select multiple options, when set the type is treated as a list"
"EnableWellKnown", "Y,N", "Allow the usage of well known names such as 'http' and 'ssh'"
"EnableRanges", "Y,N", "Allow the usa of ranges, such as :code:`80:100`"
ProtocolField
------------------------------------
List field type to validate if the provided value is a valid protocol name as defined by /etc/protocols
(e.g. TCP, UDP) extended with the :code:`any` option.
..csv-table:: ProtocolField
:header:"Parameter", "Options", "Purpose"
:widths:30, 20, 40
"default", ":code:`text`", "Default value for new attributes"
"Required", "Y,N", "Mark field as required"
"ValidationMessage", ":code:`text`", "Error message on validation failure"
"BlankDesc", ":code:`text`", "Set a label for the empty option"
"Multiple", "Y,N", "Allow to select multiple options"
TextField
------------------------------------
Validate regular text using a regex.
..csv-table:: TextField
:header:"Parameter", "Options", "Purpose"
:widths:30, 20, 40
"default", ":code:`text`", "Default value for new attributes"
"Required", "Y,N", "Mark field as required"
"ValidationMessage", ":code:`text`", "Error message on validation failure"