我有一个休息服务,我的请求主体 bean 注释有 javax.validation 等,并且在一个特定字段中我收到一个编码为字符串 base64 的@NotBlank @NotNull @Pattern文件,
那么,是否有注释,或者我如何编写自定义验证注释,以便它检查字符串是否确实是 Base64 字符串?
我只需要以注释形式进行这样的验证:
try {
Base64.getDecoder().decode(someString);
return true;
} catch(IllegalArgumentException iae) {
return false;
}
Run Code Online (Sandbox Code Playgroud)
提前谢谢