diff --git a/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/BooleanField.php b/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/BooleanField.php index e92bc285c..060266744 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/BooleanField.php +++ b/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/BooleanField.php @@ -42,9 +42,12 @@ class BooleanField extends BaseField protected $internalIsContainer = false; /** - * @var string default validation message string + * {@inheritdoc} */ - protected $internalValidationMessage = "value should be a boolean (0,1)"; + protected function defaultValidationMessage() + { + return gettext('Value should be a boolean (0,1).'); + } /** * retrieve field validators for this field type @@ -52,13 +55,12 @@ class BooleanField extends BaseField */ public function getValidators() { - // regexp for validating boolean values. - $regex_mask = "/^([0,1]){1}$/"; - $validators = parent::getValidators(); if ($this->internalValue != null) { - $validators[] = new Regex(array('message' => $this->internalValidationMessage, - 'pattern' => trim($regex_mask))); + $validators[] = new Regex([ + 'message' => $this->getValidationMessage(), + 'pattern' => '/^[01]$/', + ]); } return $validators; }