Reviewnacharbeitung

This commit is contained in:
2026-06-03 21:27:08 +02:00
parent fae4bc86ad
commit 5a1c032f1b
2 changed files with 37 additions and 102 deletions
+5 -50
View File
@@ -1,71 +1,28 @@
<?php
/**
* Prüft, ob der Name die folgenden Bedingungen erfüllt:
* Buchstaben von a-z; A-Z
* Umlaute äöüÄÖÜß
* Leerzeichen und Bindestrich
* 2-50 Zeichen
*
* @param $name
* @return bool
*/
function userNameValidator($name)
{
$name = trim($name);
$namePattern = '/^[a-zA-ZäöüÄÖÜß\s-]{2,50}$/u';
if (preg_match($namePattern, $name)) {
return true;
} else {
return false;
}
return preg_match($namePattern, $name) === 1;
}
/**
* Prüft, ob die E-Mail-Adresse gültig ist
* und höchstens 100 Zeichen enthält.
*
* @param $email
* @return bool
*/
function userEmailValidator($email)
{
$email = trim($email);
if (filter_var($email, FILTER_VALIDATE_EMAIL) && mb_strlen($email) <= 100) {
return true;
} else {
return false;
}
return filter_var($email, FILTER_VALIDATE_EMAIL) !== false
&& mb_strlen($email) <= 100;
}
/**
* Prüft, ob das Passwort die folgenden Bedingungen erfüllt:
* 8-72 Zeichen
*
* @param $password
* @return bool
*/
function userPasswordValidator($password)
{
$zeichenAnzahl = mb_strlen($password);
if ($zeichenAnzahl >= 8 && $zeichenAnzahl <= 72) {
return true;
} else {
return false;
}
return $zeichenAnzahl >= 8 && $zeichenAnzahl <= 72;
}
/**
* Prüft ein optionales Passwort.
* Leeres Passwort ist erlaubt, wenn der Nutzer sein Passwort nicht ändern möchte.
* Wenn ein Passwort eingegeben wurde, gelten die normalen Passwortregeln.
*
* @param $password
* @return bool
*/
function userOptionalPasswordValidator($password)
{
if (!isset($password) || $password === '') {
@@ -73,6 +30,4 @@ function userOptionalPasswordValidator($password)
}
return userPasswordValidator($password);
}
?>
}