试图验证一个数组在一个案例中有零个或多个字符串,并且它在另一个案例中有零个或多个对象,与Joi文档挣扎:(
validate: {
headers: Joi.object({
'content-type': "application/vnd.api+json",
accept: "application/vnd.api+json"
}).options({ allowUnknown: true }),
payload : Joi.object().keys({
data : Joi.object().keys({
type: Joi.any().allow('BY_TEMPLATE').required(),
attributes: Joi.object({
to : Joi.string().email().required(),
templateId : Joi.string().required(),
categories : Joi.array().items( //trying to validate here that each element is a string),
variables : Joi.array({
//also trying to validate here that each element is an Object with one key and value
})
})
}).required()
})
}
Run Code Online (Sandbox Code Playgroud) 寻找有关正确处理验证错误的Spring数据休息验证的一些帮助:
我对这里关于spring-data-rest验证的文档非常困惑:http://docs.spring.io/spring-data/rest/docs/current/reference/html/#validation
我正在尝试正确处理试图保存新公司实体的POST调用的验证
我有这个实体:
@Entity
public class Company implements Serializable {
@Id
@GeneratedValue
private Long id;
@NotNull
private String name;
private String address;
private String city;
private String country;
private String email;
private String phoneNumber;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "company")
private Set<Owner> owners = new HashSet<>();
public Company() {
super();
}
Run Code Online (Sandbox Code Playgroud)
...
和这个RestResource dao
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.rest.core.annotation.RestResource;
import com.domain.Company;
@RestResource
public interface CompanyDao extends PagingAndSortingRepository<Company, Long> {
}
Run Code Online (Sandbox Code Playgroud)
POST请求api /公司:
{
"address" : "One Microsoft …
Run Code Online (Sandbox Code Playgroud) 我正在尝试从 docker 容器访问我的主机系统
已尝试以下所有内容而不是 127.0.0.1 和 localhost:
gateway.docker.internal、docker.for.mac.host.internal、host.docker.internal、docker.for.mac.host.internal、docker.for.mac.localhost、
但似乎都不起作用。
如果我使用 --net=host 运行 docker run 命令,我确实可以访问 localhost,但是我的端口映射都不会暴露并且无法从外部 docker 访问。
我使用的是 Docker 版本 20.10.5,内部版本 55c4c88
更多信息。我正在运行一个名为 impervious 的软件(比特币闪电网络之上的一层)。它需要连接到本地主机 10001 上的本地 Polar 闪电节点。这是工具本身使用的配置文件(请参阅lnd
部分):
# Server configurations
server:
enabled: true # enable the GRPC/HTTP/websocket server
grpc_addr: 0.0.0.0:8881 # SET FOR DOCKER
http_addr: 0.0.0.0:8882 # SET FOR DOCKER
# Redis DB configurations
sqlite3:
username: admin
password: supersecretpassword # this will get moved to environment variable or generated dynamically
###### DO NOT EDIT THE …
Run Code Online (Sandbox Code Playgroud) 我正在尝试为我刚刚创建的用户获取 AWS 凭证。
谁能告诉我identityId
应该是什么?我曾尝试将区域与用户 sub 连接,但它没有:
var params = {
UserPoolId: process.env.USER_POOL_ID,
Username: 'xxx@gmail.com',
TemporaryPassword: 'Passw0rd!'
};
var cognitoidentityserviceprovider = new AWS.CognitoIdentityServiceProvider();
cognitoidentityserviceprovider.adminCreateUser(params, function(err, data) {
if (err) {
callback(null, failure(err));
}else
var identityId = "us-east-1:" + data.User.Username //user sub
var cognitoidentity = new AWS.CognitoIdentity();
cognitoidentity.getCredentialsForIdentity(
{"IdentityId": identityId},
(err, credResult) => {
if(err){
callback(null, failure(err));
}
callback(null, success(credResult));
})
});
Run Code Online (Sandbox Code Playgroud)
我只是得到:
{
"message":"Identity 'us-east-1:8ce7ee63-d9ae-4f12-9xxxxxx' not found.",
"code":"ResourceNotFoundException","t": "..."
}
Run Code Online (Sandbox Code Playgroud) 有没有办法可以验证这样的值,Joi
以便我可以验证它是一个零或多个键(任何名称)的对象,并且每个都有字符串,数字或布尔值?
{
dynamicallyNamedKey1: 'some value',
dynamicallyNamedKey2: 4
}
Run Code Online (Sandbox Code Playgroud) 例如,当使用亚马逊的SQS时,我可以定义一个死信队列(DLQ),其中任何在X重试之后未能被删除(确认)的消息将被路由到单独的处理..但是谷歌云平台我不知道没有提到这一点
如何使用Joi验证具有零个或多个键/值对的替换字段?并且每个键是一个字符串,并且每个值是一个字符串,数字或布尔值?
"substitutions": {
"somekey": "someval",
"somekey": "someval"
}
Run Code Online (Sandbox Code Playgroud) 我有一个spring数据JPA存储库(位于postgres db上),我有时需要使用nativeQuery = true选项来使用本机查询。
但是,在当前情况下,我需要传递一个order字段,并且这样做是这样的:
电话..
targetStatusHistoryRepository.findSirenAlarmTimeActivation([uuid,uuid2],"activation_name DESC", 0, 10)
Run Code Online (Sandbox Code Playgroud)
..回购方法
@Query(
nativeQuery = true,
value = """select
a.name as activation_name,
min(transition_from_active_in_millis),
max(transition_from_active_in_millis),
avg(transition_from_active_in_millis) from target_status_history t, activation_scenario a
where t.activation_uuid=a.activation_scenario_id and t.transition_from_active_in_millis > 0 and t.activation_uuid in (:activationUUIDs) group by a.name,t.activation_uuid
order by :orderClause offset :offset limit :limit """
)
List<Object[]> findSirenAlarmTimeActivation(@Param("activationUUIDs") List<UUID> activationUUIDs,
@Param("orderClause") String orderClause, @Param("offset") int offset, @Param("limit") int limit )
Run Code Online (Sandbox Code Playgroud)
我用DESC写了一个单元测试,然后用ASC调用,反之亦然,看来第一个调用是什么,第二个给出了相同的结果。
joi ×3
aws-cognito ×1
docker ×1
hapijs ×1
javascript ×1
jhipster ×1
jpa ×1
native ×1
postgresql ×1
spring ×1
spring-boot ×1
spring-rest ×1
sql ×1
validation ×1