UNPKG

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