How can I get programmatic error codes from Cognito mode?

0 votes

I'm using the Cognito Javascript SDK and created a form where a user can register an Account. If for any reason, server-side validation fails, the response to it is like below:

{
  "__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}]+"
}

The issue with the response is that I cannot provide a good user feedback because I'd have to parse the response to determine which fields need to be fixed. Is there any way to get the errors back in a format which is better for working in a programmatic manner?

Jun 8, 2018 in AWS by DragonLord999
• 8,380 points
194 views

1 answer to this question.

0 votes
The best way to do this is to grab the values programmatically by cutting the substrings out after 'value at'.

I didn't get an example of the libraries that might help in fixing or even doing this but this is good feedback though.
answered Jun 8, 2018 by Cloud gunner
• 4,260 points

Related Questions In AWS

0 votes
1 answer
0 votes
1 answer

How can i copy tables from one database to other on AWS?

You can use AWS Data pipeline to ...READ MORE

answered Jul 5, 2018 in AWS by Priyaj
• 56,160 points
42 views
0 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 56,160 points
99 views
+13 votes
2 answers
0 votes
1 answer

How can I return XML from boto calls?

I don't think there's an officially supported ...READ MORE

answered Jul 20, 2018 in AWS by Cloud gunner
• 4,260 points
70 views