Reviewnacharbeitung

This commit is contained in:
2026-06-03 20:58:26 +02:00
parent bfc9ee4d01
commit a0a79e0191
6 changed files with 209 additions and 133 deletions
+78
View File
@@ -0,0 +1,78 @@
<?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;
}
}
/**
* 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;
}
}
/**
* 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;
}
}
/**
* 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 === '') {
return true;
}
return userPasswordValidator($password);
}
?>