Accept dashes and spaces in names
Change-Id: Ie3729175c1f739bb0be4402e9be1e2a1921da752
diff --git a/validators.php b/validators.php
index 966f1d1..7e62bea 100644
--- a/validators.php
+++ b/validators.php
@@ -49,7 +49,7 @@
include "config.php";
include $TEMPLATE . 'strings.php';
$error = "";
- if (preg_match("/\s/", $name)) {
+ if (preg_match("/^\s/", $name)) {
$error = $error . $ERRORS->no_whitespaces;
}
if (strlen($name) > $VAL_USER->max_first_name) {
@@ -57,8 +57,9 @@
}
if (strlen($name) < $VAL_USER->min_first_name) {
$error = $error . format($ERRORS->bigger_than, ["num" => $VAL_USER->min_first_name - 1]);
+ $error += "actual length: " . strlen($name);
}
- if (preg_match('/[\'\/~`\!@#\$%\^&\*\(\)_\-\+=\{\}\[\]\|;:"\<\>,\.\?\\\0-9]/', $name)) {
+ if (preg_match('/[\'\/~`\!@#\$%\^&\*\(\)_\-\+=\{\}\[\]\|;:"\<\>,\.\?\\\0-9]-/', $name)) {
$error = $error . $ERRORS->no_special_chars;
}
return $error;