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

Fixes #5554 Added feature to trim value in string attributes

parent e1958962
......@@ -26,6 +26,7 @@ class StringAttribute extends Attribute
protected $pattern;
protected $example;
protected $autocomplete = NULL;
protected $trim = FALSE;
/*! \brief The constructor of StringAttribute
*
......@@ -105,6 +106,23 @@ class StringAttribute extends Attribute
{
return $this->autocomplete;
}
function setValue ($value)
{
if ($this->trim) {
return parent::setValue(trim($value));
} else {
return parent::setValue($value);
}
}
}
/*! \brief This class allow to handle easily a String LDAP attribute that appears as a text area
*
*/
class TrimmedStringAttribute extends StringAttribute
{
protected $trim = TRUE;
}
/*! \brief This class allow to handle easily a String LDAP attribute that appears as a text area
......
......@@ -23,6 +23,8 @@
*/
class MailAttribute extends StringAttribute
{
protected $trim = TRUE;
function validate ()
{
if (!tests::is_email($this->value)) {
......@@ -69,6 +71,8 @@ class UidAttribute extends TestValidateAttribute
*/
class PathAttribute extends TestValidateAttribute
{
protected $trim = TRUE;
protected $testFunc = 'is_path';
}
......@@ -77,6 +81,8 @@ class PathAttribute extends TestValidateAttribute
*/
class URLAttribute extends TestValidateAttribute
{
protected $trim = TRUE;
protected $testFunc = 'is_url';
}
......@@ -85,6 +91,8 @@ class URLAttribute extends TestValidateAttribute
*/
class PhoneNumberAttribute extends TestValidateAttribute
{
protected $trim = TRUE;
protected $testFunc = 'is_phone_nr';
}
......@@ -93,6 +101,8 @@ class PhoneNumberAttribute extends TestValidateAttribute
*/
class IPAttribute extends TestValidateAttribute
{
protected $trim = TRUE;
protected $testFunc = 'is_ip';
}
......@@ -101,6 +111,8 @@ class IPAttribute extends TestValidateAttribute
*/
class IPv4Attribute extends TestValidateAttribute
{
protected $trim = TRUE;
protected $testFunc = 'is_ipv4';
}
......@@ -109,6 +121,8 @@ class IPv4Attribute extends TestValidateAttribute
*/
class IPv6Attribute extends TestValidateAttribute
{
protected $trim = TRUE;
protected $testFunc = 'is_ipv6';
}
......@@ -117,6 +131,8 @@ class IPv6Attribute extends TestValidateAttribute
*/
class MacAddressAttribute extends StringAttribute
{
protected $trim = TRUE;
function setValue ($value)
{
return parent::setValue(strtolower($value));
......
Markdown is supported
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