Commit 06206e03 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

:sparkles: feat(MacAttribute) Use pattern HTML5 attribute for Mac Address as well

issue #5910
Showing with 5 additions and 7 deletions
+5 -7
...@@ -166,7 +166,7 @@ class tests ...@@ -166,7 +166,7 @@ class tests
*/ */
public static function is_mac($mac) public static function is_mac($mac)
{ {
return preg_match("/^[a-f0-9][a-f0-9]:[a-f0-9][a-f0-9]:[a-f0-9][a-f0-9]:[a-f0-9][a-f0-9]:[a-f0-9][a-f0-9]:[a-f0-9][a-f0-9]$/i", $mac); return preg_match('/^([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}$/', $mac);
} }
......
...@@ -118,16 +118,14 @@ class MacAddressAttribute extends StringAttribute ...@@ -118,16 +118,14 @@ class MacAddressAttribute extends StringAttribute
{ {
protected $trim = TRUE; protected $trim = TRUE;
function setValue ($value) function __construct ($label, $description, $ldapName, $required = FALSE, $defaultValue = '', $acl = '')
{ {
return parent::setValue(strtolower($value)); parent::__construct($label, $description, $ldapName, $required, $defaultValue, $acl, '/^([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}$/', '5E:FF:56:A2:AF:15');
} }
function validate () function setValue ($value)
{ {
if (!tests::is_mac($this->value)) { return parent::setValue(strtolower($value));
return msgPool::invalid($this->getLabel(), $this->value);
}
} }
} }
......
  • SonarQube analysis reported 1 issue

    • :arrow_down_small: 1 minor

    Note: The following issues were found on lines that were not modified in the commit. Because these issues can't be reported as line comments, they are summarized here:

    1. :arrow_down_small: Remove this method "__construct" to simply inherit it. :blue_book:

    By Ghost User on 2018-10-17T09:08:52 (imported from GitLab)

Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment