自定义验证器验证对象键

问题描述

我用一个打字稿项目构建了nestjs,我正在尝试验证过滤器查询参数。 我只希望过滤键和值可以通过验证。 好的参数示例:通过验证

    public List<GrantedAuthority> getAuthorities(String token) {
    String[] claims = getClaimsFromToken(token);
    return StreamSupport.stream(claims).map(SimpleGrantedAuthority::new).collect(Collectors.toList());
}

错误参数示例:验证失败

any-endpoint?filters={"userIds"=["1","2","5"],"ages"=[25]}

any-endpoint?filters={"names"=["david","samuel"],"ages"=[21]}

我的代码

any-endpoint?filters={"blaBla"=["1","ages"=[25]} // here the key blaBla not one of the filters options

any-endpoint?filters={"names"=[1,2]} // here the values of names is not string,it should be string

怎么做?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)