1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | import { I18n } from '@aws-amplify/core';
|
14 | export var MapEntries = [
|
15 | ['User does not exist', /user.*not.*exist/i],
|
16 | ['User already exists', /user.*already.*exist/i],
|
17 | ['Incorrect username or password', /incorrect.*username.*password/i],
|
18 | ['Invalid password format', /validation.*password/i],
|
19 | [
|
20 | 'Invalid phone number format',
|
21 | /invalid.*phone/i,
|
22 | 'Invalid phone number format. Please use a phone number format of +12345678900',
|
23 | ],
|
24 | ];
|
25 | export function AmplifyMessageMap(message) {
|
26 |
|
27 | var match = MapEntries.filter(function (entry) { return entry[1].test(message); });
|
28 | if (match.length === 0) {
|
29 | return message;
|
30 | }
|
31 | var entry = match[0];
|
32 | var msg = entry.length > 2 ? entry[2] : entry[0];
|
33 | return I18n.get(entry[0], msg);
|
34 | }
|
35 |
|
\ | No newline at end of file |