UNPKG

1.43 kBJavaScriptView Raw
1/*
2 * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
5 * the License. A copy of the License is located at
6 *
7 * http://aws.amazon.com/apache2.0/
8 *
9 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
10 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
11 * and limitations under the License.
12 */
13import { I18n } from '@aws-amplify/core';
14export 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];
25export function AmplifyMessageMap(message) {
26 // @ts-ignore
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//# sourceMappingURL=AmplifyMessageMap.js.map
\No newline at end of file