class FileValidator implements ConstraintValidator<IsFile, File> {

    @Override
    public boolean isValid(File value, ConstraintValidatorContext context) {
        if (value != null && value.exists()) {
            return value.isFile();
        }
        return true;
    }

}