Throw a dedicated exception for fully empty actor descriptions in

NodaValidationHelper
This commit is contained in:
Joshua Ramon Enslin 2022-05-26 18:02:05 +02:00
parent c00cb6b629
commit 027d4b3506
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE

View File

@ -27,6 +27,13 @@ final class NodaValidationHelper {
*/ */
public static function validateActorDescription(string $description, array $names = []):void { public static function validateActorDescription(string $description, array $names = []):void {
// For nodac, empty actor descriptions are to be allowed. Thus, a
// dedicated check for fully empty ones with a dedicated exception
// is needed.
if (empty($description)) {
throw new MDInvalidEmptyInputException("No author name is provided");
}
// Throw error on descriptions that are too short // Throw error on descriptions that are too short
if (\mb_strlen($description) < 10) { if (\mb_strlen($description) < 10) {
throw new MDgenericInvalidInputsException("Author description is too short"); throw new MDgenericInvalidInputsException("Author description is too short");