gpt4 book ai didi

amazon-web-services - 如何从 Cognito 获取编程错误代码?

转载 作者:行者123 更新时间:2023-12-04 17:51:59 25 4
gpt4 key购买 nike

我正在使用 Cognito Javscript SDK,并且我创建了一个表单,用户可以在其中注册帐户。如果出于某种原因服务器端验证失败,则响应如下所示:

{
"__type":"InvalidParameterException",
"message":"4 validation errors detected: Value at 'password' failed to satisfy constraint: Member must have length greater than or equal to 6; Value at 'password' failed to satisfy constraint: Member must satisfy regular expression pattern: [\\S]+; Value at 'username' failed to satisfy constraint: Member must have length greater than or equal to 1; Value at 'username' failed to satisfy constraint: Member must satisfy regular expression pattern: [\\p{L}\\p{M}\\p{S}\\p{N}\\p{P}]+"
}

此响应的问题是我无法提供良好的用户反馈,因为我必须解析响应以确定需要修复哪些字段。有没有办法以更适合以编程方式处理的格式恢复错误?

最佳答案

目前执行此操作的最佳方法是通过删除“value at”之后的子字符串以编程方式获取值。

我还没有任何图书馆的例子可以帮助做到这一点,但这是很好的反馈。

关于amazon-web-services - 如何从 Cognito 获取编程错误代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43957836/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com