-
Notifications
You must be signed in to change notification settings - Fork 79
/
Copy pathsimple-react-validator.js
552 lines (548 loc) · 24.9 KB
/
simple-react-validator.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
// Simple React Validator v1.6.2 | Created By Dockwa | MIT License | 2017 - Present
;(function(root, factory) {
if (typeof define === 'function' && define.amd) {
define(['react'], factory);
} else if (typeof exports === 'object') {
module.exports = factory(require('react'));
} else {
root.SimpleReactValidator = factory(root.React);
}
}(this, function(React) {
"use strict";
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var SimpleReactValidator = /*#__PURE__*/function () {
function SimpleReactValidator() {
var _this = this;
var _options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
_classCallCheck(this, SimpleReactValidator);
_defineProperty(this, "showMessageFor", function (field) {
if (!_this.visibleFields.includes(field)) {
_this.visibleFields.push(field);
}
_this.helpers.forceUpdateIfNeeded();
});
_defineProperty(this, "hideMessageFor", function (field) {
var index = _this.visibleFields.indexOf(field);
if (index > -1) {
_this.visibleFields.splice(index, 1);
}
_this.helpers.forceUpdateIfNeeded();
});
_defineProperty(this, "helpers", {
parent: this,
passes: function passes(rule, value, params, rules) {
if (!rules.hasOwnProperty(rule)) {
console.error("Rule Not Found: There is no rule with the name ".concat(rule, "."));
return true;
}
if (!this.isRequired(rule, rules) && this.isBlank(value)) {
return true;
}
return rules[rule].rule(value, params, this.parent) !== false;
},
isRequired: function isRequired(rule, rules) {
return rules[rule].hasOwnProperty('required') && rules[rule].required;
},
isBlank: function isBlank(value) {
return typeof value === 'undefined' || value === null || this.testRegex(value, /^[\s]*$/);
},
normalizeValues: function normalizeValues(value, validation) {
return [this.valueOrEmptyString(value), this.getValidation(validation), this.getOptions(validation)];
},
getValidation: function getValidation(validation) {
if (validation === Object(validation) && !!Object.keys(validation).length) {
return Object.keys(validation)[0];
} else {
return validation.split(':')[0];
}
},
getOptions: function getOptions(validation) {
if (validation === Object(validation) && !!Object.values(validation).length) {
var params = Object.values(validation)[0];
return Array.isArray(params) ? params : [params];
} else {
var params = validation.split(':');
return params.length > 1 ? params[1].split(',') : [];
}
},
valueOrEmptyString: function valueOrEmptyString(value) {
return typeof value === 'undefined' || value === null ? '' : value;
},
toSentence: function toSentence(arr) {
return arr.slice(0, -2).join(', ') + (arr.slice(0, -2).length ? ', ' : '') + arr.slice(-2).join(arr.length > 2 ? ', or ' : ' or ');
},
testRegex: function testRegex(value, regex) {
return value.toString().match(regex) !== null;
},
forceUpdateIfNeeded: function forceUpdateIfNeeded() {
if (this.parent.autoForceUpdate) {
this.parent.autoForceUpdate.forceUpdate();
}
},
message: function message(rule, field, options, rules) {
options.messages = options.messages || {};
var message = options.messages[rule] || options.messages["default"] || this.parent.messages[rule] || this.parent.messages["default"] || rules[rule].message;
return message.replace(':attribute', this.humanizeFieldName(field));
},
humanizeFieldName: function humanizeFieldName(field) {
// supports snake_case or camelCase
return field.replace(/([a-z0-9])([A-Z])/g, '$1 $2').replace(/_/g, ' ').toLowerCase();
},
element: function element(message, options) {
var element = options.element || this.parent.element;
return element(message, options.className);
},
momentInstalled: function momentInstalled() {
if (!window || !window.moment) {
console.warn('Date validators require using momentjs https://momentjs.com and moment objects.');
return false;
} else {
return true;
}
},
size: function size(val, type) {
// if an array or string get the length, else return the value.
if (type === 'string' || type === undefined || type === 'array') {
return val.length;
} else if (type === 'num') {
return parseFloat(val);
}
},
sizeText: function sizeText(type) {
if (type === 'string' || type === undefined) {
return ' characters';
} else if (type === 'array') {
return ' elements';
} else {
return '';
}
}
});
this.fields = {};
this.visibleFields = [];
this.errorMessages = {};
this.messagesShown = false;
this.rules = _objectSpread({
accepted: {
message: 'The :attribute must be accepted.',
rule: function rule(val) {
return val === true;
},
required: true
},
after: {
message: 'The :attribute must be after :date.',
rule: function rule(val, params) {
return _this.helpers.momentInstalled() && moment.isMoment(val) && val.isAfter(params[0], 'day');
},
messageReplace: function messageReplace(message, params) {
return message.replace(':date', params[0].format('MM/DD/YYYY'));
}
},
after_or_equal: {
message: 'The :attribute must be after or on :date.',
rule: function rule(val, params) {
return _this.helpers.momentInstalled() && moment.isMoment(val) && val.isSameOrAfter(params[0], 'day');
},
messageReplace: function messageReplace(message, params) {
return message.replace(':date', params[0].format('MM/DD/YYYY'));
}
},
alpha: {
message: 'The :attribute may only contain letters.',
rule: function rule(val) {
return _this.helpers.testRegex(val, /^[A-Z]*$/i);
}
},
alpha_space: {
message: 'The :attribute may only contain letters and spaces.',
rule: function rule(val) {
return _this.helpers.testRegex(val, /^[A-Z\s]*$/i);
}
},
alpha_num: {
message: 'The :attribute may only contain letters and numbers.',
rule: function rule(val) {
return _this.helpers.testRegex(val, /^[A-Z0-9]*$/i);
}
},
alpha_num_space: {
message: 'The :attribute may only contain letters, numbers, and spaces.',
rule: function rule(val) {
return _this.helpers.testRegex(val, /^[A-Z0-9\s]*$/i);
}
},
alpha_num_dash: {
message: 'The :attribute may only contain letters, numbers, and dashes.',
rule: function rule(val) {
return _this.helpers.testRegex(val, /^[A-Z0-9_-]*$/i);
}
},
alpha_num_dash_space: {
message: 'The :attribute may only contain letters, numbers, dashes, and spaces.',
rule: function rule(val) {
return _this.helpers.testRegex(val, /^[A-Z0-9_-\s]*$/i);
}
},
array: {
message: 'The :attribute must be an array.',
rule: function rule(val) {
return Array.isArray(val);
}
},
before: {
message: 'The :attribute must be before :date.',
rule: function rule(val, params) {
return _this.helpers.momentInstalled() && moment.isMoment(val) && val.isBefore(params[0], 'day');
},
messageReplace: function messageReplace(message, params) {
return message.replace(':date', params[0].format('MM/DD/YYYY'));
}
},
before_or_equal: {
message: 'The :attribute must be before or on :date.',
rule: function rule(val, params) {
return _this.helpers.momentInstalled() && moment.isMoment(val) && val.isSameOrBefore(params[0], 'day');
},
messageReplace: function messageReplace(message, params) {
return message.replace(':date', params[0].format('MM/DD/YYYY'));
}
},
between: {
message: 'The :attribute must be between :min and :max:type.',
rule: function rule(val, params) {
return _this.helpers.size(val, params[2]) >= parseFloat(params[0]) && _this.helpers.size(val, params[2]) <= parseFloat(params[1]);
},
messageReplace: function messageReplace(message, params) {
return message.replace(':min', params[0]).replace(':max', params[1]).replace(':type', _this.helpers.sizeText(params[2]));
}
},
"boolean": {
message: 'The :attribute must be a boolean.',
rule: function rule(val) {
return val === false || val === true;
}
},
card_exp: {
message: 'The :attribute must be a valid expiration date.',
rule: function rule(val) {
return _this.helpers.testRegex(val, /^(([0]?[1-9]{1})|([1]{1}[0-2]{1}))\s?\/\s?(\d{2}|\d{4})$/);
}
},
card_num: {
message: 'The :attribute must be a valid credit card number.',
rule: function rule(val) {
return _this.helpers.testRegex(val, /^\d{4}\s?\d{4,6}\s?\d{4,5}\s?\d{0,8}$/);
}
},
currency: {
message: 'The :attribute must be a valid currency.',
rule: function rule(val) {
return _this.helpers.testRegex(val, /^[\$£€¥]?(\d{1,3})(\,?\d{3})*\.?\d{0,2}$/);
}
},
date: {
message: 'The :attribute must be a date.',
rule: function rule(val) {
return _this.helpers.momentInstalled() && moment.isMoment(val);
}
},
date_equals: {
message: 'The :attribute must be on :date.',
rule: function rule(val, params) {
return _this.helpers.momentInstalled() && moment.isMoment(val) && val.isSame(params[0], 'day');
},
messageReplace: function messageReplace(message, params) {
return message.replace(':date', params[0].format('MM/DD/YYYY'));
}
},
email: {
message: 'The :attribute must be a valid email address.',
rule: function rule(val) {
return _this.helpers.testRegex(val, /^[A-Z0-9.!#$%&'*+-/=?^_`{|}~]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i);
}
},
"in": {
message: 'The selected :attribute must be :values.',
rule: function rule(val, params) {
return params.includes(val);
},
messageReplace: function messageReplace(message, params) {
return message.replace(':values', _this.helpers.toSentence(params));
}
},
integer: {
message: 'The :attribute must be an integer.',
rule: function rule(val) {
return _this.helpers.testRegex(val, /^\-?\d*$/);
}
},
max: {
message: 'The :attribute may not be greater than :max:type.',
rule: function rule(val, params) {
return _this.helpers.size(val, params[1]) <= parseFloat(params[0]);
},
messageReplace: function messageReplace(message, params) {
return message.replace(':max', params[0]).replace(':type', _this.helpers.sizeText(params[1]));
}
},
min: {
message: 'The :attribute must be at least :min:type.',
rule: function rule(val, params) {
return _this.helpers.size(val, params[1]) >= parseFloat(params[0]);
},
messageReplace: function messageReplace(message, params) {
return message.replace(':min', params[0]).replace(':type', _this.helpers.sizeText(params[1]));
}
},
not_in: {
message: 'The selected :attribute must not be :values.',
rule: function rule(val, params) {
return !params.includes(val);
},
messageReplace: function messageReplace(message, params) {
return message.replace(':values', _this.helpers.toSentence(params));
}
},
not_regex: {
message: 'The :attribute must not match the required pattern.',
rule: function rule(val, params) {
return !_this.helpers.testRegex(val, typeof params[0] === 'string' || params[0] instanceof String ? new RegExp(params[0]) : params[0]);
}
},
numeric: {
message: 'The :attribute must be a number.',
rule: function rule(val) {
return _this.helpers.testRegex(val, /^\-?\d*\.?\d+$/);
}
},
phone: {
message: 'The :attribute must be a valid phone number.',
rule: function rule(val) {
return _this.helpers.testRegex(val, /^(\+?\d{0,4})?\s?-?\s?(\(?\d{3}\)?)\s?-?\s?(\(?\d{3}\)?)\s?-?\s?(\(?\d{4}\)?)$/) && !_this.helpers.testRegex(val, /^\b(\d)\1{8,}\b$/);
}
},
regex: {
message: 'The :attribute must match the required pattern.',
rule: function rule(val, params) {
return _this.helpers.testRegex(val, typeof params[0] === 'string' || params[0] instanceof String ? new RegExp(params[0]) : params[0]);
}
},
required: {
message: 'The :attribute field is required.',
rule: function rule(val) {
return !_this.helpers.isBlank(val);
},
required: true
},
size: {
message: 'The :attribute must be :size:type.',
rule: function rule(val, params) {
return _this.helpers.size(val, params[1]) == parseFloat(params[0]);
},
messageReplace: function messageReplace(message, params) {
return message.replace(':size', params[0]).replace(':type', _this.helpers.sizeText(params[1]));
}
},
string: {
message: 'The :attribute must be a string.',
rule: function rule(val) {
return _typeof(val) === _typeof('string');
}
},
"typeof": {
message: 'The :attribute is not the correct type of :type.',
rule: function rule(val, params) {
return _typeof(val) === _typeof(params[0]);
},
messageReplace: function messageReplace(message, params) {
return message.replace(':type', _typeof(params[0]));
}
},
url: {
message: 'The :attribute must be a url.',
rule: function rule(val) {
return _this.helpers.testRegex(val, /^https?:\/\/[-a-z0-9@:%._\+~#=]{1,256}\.[a-z0-9()]{2,13}\b([-a-z0-9()@:%_\+.~#?&//=]*)$/i);
}
}
}, _options.validators || {});
// apply language
if (_options.locale && !SimpleReactValidator.locales.hasOwnProperty(_options.locale)) {
console.warn('Locale not found! Make sure it is spelled correctly and the locale file is loaded.');
}
var locale = SimpleReactValidator.locales[_options.locale] || {};
Object.keys(this.rules).forEach(function (key) {
_this.rules[key].message = locale[key] || _this.rules[key].message;
});
// apply default options
this.messages = _options.messages || {};
this.className = _options.className;
this.autoForceUpdate = _options.autoForceUpdate || false;
// apply default element
if (_options.element === false) {
this.element = function (message) {
return message;
};
} else if (_options.hasOwnProperty('element')) {
this.element = _options.element;
} else if ((typeof navigator === "undefined" ? "undefined" : _typeof(navigator)) === 'object' && navigator.product === 'ReactNative') {
this.element = function (message) {
return message;
};
} else {
this.element = function (message, className) {
return React.createElement('div', {
className: className || _this.className || 'srv-validation-message'
}, message);
};
}
}
_createClass(SimpleReactValidator, [{
key: "getErrorMessages",
value: function getErrorMessages() {
return this.errorMessages;
}
}, {
key: "showMessages",
value: function showMessages() {
this.messagesShown = true;
this.helpers.forceUpdateIfNeeded();
}
}, {
key: "hideMessages",
value: function hideMessages() {
this.messagesShown = false;
this.helpers.forceUpdateIfNeeded();
}
}, {
key: "allValid",
value: function allValid() {
for (var key in this.fields) {
if (this.fieldValid(key) === false) {
return false;
}
}
return true;
}
}, {
key: "fieldValid",
value: function fieldValid(field) {
return this.fields.hasOwnProperty(field) && this.fields[field] === true;
}
}, {
key: "purgeFields",
value: function purgeFields() {
this.fields = {};
this.errorMessages = {};
}
}, {
key: "messageWhenPresent",
value: function messageWhenPresent(message) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
if (!this.helpers.isBlank(message) && this.messagesShown) {
return this.helpers.element(message, options);
}
}
}, {
key: "messageAlways",
value: function messageAlways(field, message) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
console.warn('The messageAlways() method is deprecated in SimpleReactValidator. Please see the documentation and switch to the messageWhenPresent() method.');
if (message && this.messagesShown) {
return this.helpers.element(message, options);
}
}
}, {
key: "check",
value: function check(inputValue, validations) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
if (!Array.isArray(validations)) {
validations = validations.split('|');
}
var rules = options.validators ? _objectSpread(_objectSpread({}, this.rules), options.validators) : this.rules;
var _iterator = _createForOfIteratorHelper(validations),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var validation = _step.value;
var _this$helpers$normali = this.helpers.normalizeValues(inputValue, validation),
_this$helpers$normali2 = _slicedToArray(_this$helpers$normali, 3),
value = _this$helpers$normali2[0],
rule = _this$helpers$normali2[1],
params = _this$helpers$normali2[2];
if (!this.helpers.passes(rule, value, params, rules)) {
return false;
}
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
return true;
}
}, {
key: "message",
value: function message(field, inputValue, validations) {
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
this.errorMessages[field] = null;
this.fields[field] = true;
if (!Array.isArray(validations)) {
validations = validations.split('|');
}
var rules = options.validators ? _objectSpread(_objectSpread({}, this.rules), options.validators) : this.rules;
var _iterator2 = _createForOfIteratorHelper(validations),
_step2;
try {
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
var validation = _step2.value;
var _this$helpers$normali3 = this.helpers.normalizeValues(inputValue, validation),
_this$helpers$normali4 = _slicedToArray(_this$helpers$normali3, 3),
value = _this$helpers$normali4[0],
rule = _this$helpers$normali4[1],
params = _this$helpers$normali4[2];
if (!this.helpers.passes(rule, value, params, rules)) {
this.fields[field] = false;
var message = this.helpers.message(rule, field, options, rules);
if (params.length > 0 && rules[rule].hasOwnProperty('messageReplace')) {
message = rules[rule].messageReplace(message, params);
}
this.errorMessages[field] = message;
if (this.messagesShown || this.visibleFields.includes(field)) {
return this.helpers.element(message, options);
}
}
}
} catch (err) {
_iterator2.e(err);
} finally {
_iterator2.f();
}
}
}], [{
key: "addLocale",
value: function addLocale(lang, messages) {
this.locales[lang] = messages;
}
}]);
return SimpleReactValidator;
}();
_defineProperty(SimpleReactValidator, "version", '1.5.1');
_defineProperty(SimpleReactValidator, "locales", {
'en': {}
});
return SimpleReactValidator;
}));