UNPKG

1.56 kBJavaScriptView Raw
1"use strict";
2/*
3 * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
6 * the License. A copy of the License is located at
7 *
8 * http://aws.amazon.com/apache2.0/
9 *
10 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
11 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
12 * and limitations under the License.
13 */
14Object.defineProperty(exports, "__esModule", { value: true });
15var core_1 = require("@aws-amplify/core");
16exports.MapEntries = [
17 ['User does not exist', /user.*not.*exist/i],
18 ['User already exists', /user.*already.*exist/i],
19 ['Incorrect username or password', /incorrect.*username.*password/i],
20 ['Invalid password format', /validation.*password/i],
21 [
22 'Invalid phone number format',
23 /invalid.*phone/i,
24 'Invalid phone number format. Please use a phone number format of +12345678900',
25 ],
26];
27function AmplifyMessageMap(message) {
28 // @ts-ignore
29 var match = exports.MapEntries.filter(function (entry) { return entry[1].test(message); });
30 if (match.length === 0) {
31 return message;
32 }
33 var entry = match[0];
34 var msg = entry.length > 2 ? entry[2] : entry[0];
35 return core_1.I18n.get(entry[0], msg);
36}
37exports.AmplifyMessageMap = AmplifyMessageMap;
38//# sourceMappingURL=AmplifyMessageMap.js.map
\No newline at end of file