创建和更新用户名校验增加校验,不允许纯数字用户名

This commit is contained in:
zhoujia
2025-09-05 15:08:22 +08:00
parent 5dab838482
commit 5534573a19

View File

@@ -1,6 +1,7 @@
package com.openisle.service;
import com.openisle.exception.FieldException;
import org.apache.commons.lang3.math.NumberUtils;
import org.springframework.stereotype.Service;
/**
@@ -17,6 +18,11 @@ public class UsernameValidator {
if (username == null || username.isEmpty()) {
throw new FieldException("username", "Username cannot be empty");
}
if (NumberUtils.isDigits(username)) {
throw new FieldException("username", "Username cannot be pure number");
}
}
}