Admin: Pruefung des Mitarbeiter-Formulars als Lib mit Test
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
313ead77f4
commit
38beaead99
2 files changed
+41
No files matched your search
@@ -0,0 +1,20 @@
|
||||
// Prüfung des Mitarbeiter-Formulars (Admin). Rein, unter Node testbar.
|
||||
|
||||
const NEED = 'Name und E-Mail sind erforderlich.'
|
||||
const MIN_PASSWORD = 8
|
||||
|
||||
/**
|
||||
* Prüft das Formular zum Anlegen (isEdit false) oder Bearbeiten (isEdit true).
|
||||
* Gibt den deutschen Fehlertext zurück, null heißt gültig. Beim Bearbeiten
|
||||
* heißt ein leeres Passwort „unverändert“.
|
||||
*/
|
||||
export function validateEmployeeForm(form, isEdit) {
|
||||
if (!form.displayName.trim() || !form.email.trim()) return NEED
|
||||
if (!isEdit && form.password.length < MIN_PASSWORD) {
|
||||
return 'Das Passwort muss mindestens 8 Zeichen haben.'
|
||||
}
|
||||
if (isEdit && form.password && form.password.length < MIN_PASSWORD) {
|
||||
return 'Ein neues Passwort muss mindestens 8 Zeichen haben.'
|
||||
}
|
||||
return null
|
||||
}
|
||||
Reference in new issue
Block a user