我已经对 MultipartFile 进行了自定义验证。
class ImageCommand implements Validateable {
MultipartFile imageFile
static constraints = {
imageFile validator: { val, obj ->
if ( val == null ) {
return false
}
if ( val.empty ) {
return false
}
['jpeg', 'jpg', 'png'].any { extension ->
val.originalFilename?.toLowerCase()?.endsWith(extension)
}
}
}}
但是我现在需要多个文件,我想更改自定义验证以获取列表并应用约束。
<input type="file" id="imageFile1" name="imageFile">
to
<input type="file" id="imageFile1" name="imageFiles">
<input type="file" id="imageFile2" name="imageFiles">
知道如何在自定义验证中使用集合吗???