Cognito注册时的电话号码格式无效



我试图通过nodeJS在我的cognito用户池中创建一个新用户,但我一直收到错误的电话号码错误。。。但我使用相同格式的号码通过SNS服务发送短信,我不明白为什么会发生这种情况

注册方式:

module.exports.post = async (username,password,email,phoneNumber) => {
const environment = {
UserPoolId: xxxxxxx,
ClientId: xxxxxx,
}
return new Promise((reject,resolve) => {
const userPool = new AmazonCognitoIdentity.CognitoUserPool(environment);
const emailData = {
Name: 'Email',
Value: email
};
const userData = {
Name: 'Usuário',
Value: username
};
const phoneData = {
Name: 'Telefone',
Value: phoneNumber
};
const emailAttribute = new AmazonCognitoIdentity.CognitoUserAttribute(emailData);
const userAttribute = new AmazonCognitoIdentity.CognitoUserAttribute(userData);
const phoneAttribute = new AmazonCognitoIdentity.CognitoUserAttribute(phoneData);
userPool.signUp(username,password,[emailAttribute,userAttribute, phoneAttribute], null, (err,data) => {
if(err) console.log(err);
resolve(data);
});
});
}

正在传递的数字格式:

+5521979724910

错误:

{ code: 'InvalidParameterException',
name: 'InvalidParameterException',
message: '1 validation error detected: Value 'phone number' at 'userAttributes.2.member.name' failed to satisfy constraint: Member must satisfy regular expression pattern: [\p{L}\p{M}\p{S}\p{N}\p{P}]+' }

有什么想法吗?

Name属性值应为phone_number,而不是Telefone

const phoneData = {
Name : 'phone_number',
Value : '+15555555555'
};

使用属性名称作为'phone_number'

注意:添加国家代码和电话号码值。否则它将抛出另一个错误

最新更新