monkey-front-core 0.0.27 → 0.0.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -260,7 +260,7 @@
260
260
  return MonkeyEcxUtils;
261
261
  }());
262
262
 
263
- var moment$1 = moment___namespace;
263
+ var moment$2 = moment___namespace;
264
264
  var MonkeyEcxFormatDateTimelapsePipe = /** @class */ (function () {
265
265
  function MonkeyEcxFormatDateTimelapsePipe() {
266
266
  // not todo
@@ -274,16 +274,16 @@
274
274
  if (!format) {
275
275
  format = '- HH:mm';
276
276
  }
277
- var stillUtc = moment$1.utc(date).toDate();
277
+ var stillUtc = moment$2.utc(date).toDate();
278
278
  if (!useUtc)
279
- stillUtc = moment$1(date).toDate();
279
+ stillUtc = moment$2(date).toDate();
280
280
  if (((_a = date.toString()) === null || _a === void 0 ? void 0 : _a.indexOf(':')) <= -1) {
281
281
  stillUtc = date;
282
282
  showTime = false;
283
283
  }
284
284
  var formatFrom = "YYYY/MM/DD" + (showTime ? " " + format : '');
285
285
  var formatTo = "DD/MM/YYYY" + (showTime ? " " + format : '');
286
- return "" + moment$1(stillUtc, formatFrom).format(formatTo);
286
+ return "" + moment$2(stillUtc, formatFrom).format(formatTo);
287
287
  };
288
288
  return MonkeyEcxFormatDateTimelapsePipe;
289
289
  }());
@@ -1101,7 +1101,7 @@
1101
1101
  }
1102
1102
 
1103
1103
  /* eslint-disable max-classes-per-file */
1104
- var moment = moment___namespace;
1104
+ var moment$1 = moment___namespace;
1105
1105
  var DateValidator = /** @class */ (function () {
1106
1106
  function DateValidator() {
1107
1107
  }
@@ -1110,7 +1110,7 @@
1110
1110
  return null;
1111
1111
  if (control && control.value) {
1112
1112
  var dateFormat = 'MM-DD-YYYY';
1113
- if (!moment(moment(control.value).format(dateFormat), ['DD/MM/YYYY', 'MM-DD-YYYY', 'YYYY-MM-DD'], true).isValid()) {
1113
+ if (!moment$1(moment$1(control.value).format(dateFormat), ['DD/MM/YYYY', 'MM-DD-YYYY', 'YYYY-MM-DD'], true).isValid()) {
1114
1114
  return {
1115
1115
  invalidDate: true
1116
1116
  };
@@ -1448,6 +1448,201 @@
1448
1448
  hasMonkeyEcxServiceAndHandlingProperties: hasMonkeyEcxServiceAndHandlingProperties
1449
1449
  });
1450
1450
 
1451
+ var moment = moment___namespace;
1452
+ // eslint-disable-next-line max-len
1453
+ var EMAIL_REGEXP = /^(?=.{1,254}$)(?=.{1,64}@)([A-Za-z0-9_\-.])+@([A-Za-z0-9])+\.([A-Za-z]{1,61})$/;
1454
+ function isEmptyInputValue(value) {
1455
+ return value == null || value.length === 0;
1456
+ }
1457
+ function emailValidator(control) {
1458
+ if (!control.parent || !control || isEmptyInputValue(control.value)) {
1459
+ return null;
1460
+ }
1461
+ var test = EMAIL_REGEXP.test(control.value);
1462
+ if (test)
1463
+ return null;
1464
+ return {
1465
+ email: true
1466
+ };
1467
+ }
1468
+ function dateRangeValidator(control) {
1469
+ if (!control.parent || !control || isEmptyInputValue(control.value)) {
1470
+ return null;
1471
+ }
1472
+ var dates = control.parent.get('dates').value;
1473
+ if (dates &&
1474
+ (!MonkeyEcxUtils.persistNullEmptyUndefined(dates === null || dates === void 0 ? void 0 : dates.startDate) ||
1475
+ !MonkeyEcxUtils.persistNullEmptyUndefined(dates === null || dates === void 0 ? void 0 : dates.endDate))) {
1476
+ return {
1477
+ dateRange: true
1478
+ };
1479
+ }
1480
+ return null;
1481
+ }
1482
+ function registerValidator(control, type) {
1483
+ if (!control.parent || !control || isEmptyInputValue(control.value)) {
1484
+ return null;
1485
+ }
1486
+ if (control && control.value !== ("#MONKEY" + type).toUpperCase()) {
1487
+ return {
1488
+ invalidUnlockRegister: true
1489
+ };
1490
+ }
1491
+ return null;
1492
+ }
1493
+ function dateStartEndValidator(control) {
1494
+ if (!control.parent || !control) {
1495
+ return null;
1496
+ }
1497
+ var parent = control.parent;
1498
+ var valueStart = parent.get('dateStart').value;
1499
+ var valueEnd = parent.get('dateEnd').value;
1500
+ var dateStart;
1501
+ var dateEnd;
1502
+ if (valueStart) {
1503
+ dateStart = new Date(valueStart);
1504
+ }
1505
+ if (valueEnd) {
1506
+ dateEnd = new Date(valueEnd);
1507
+ }
1508
+ if (!dateEnd || !dateStart)
1509
+ return null;
1510
+ if (dateStart > dateEnd) {
1511
+ return {
1512
+ dateStartMustBeLessThanAnd: true
1513
+ };
1514
+ }
1515
+ return null;
1516
+ }
1517
+ function urlValidator(control) {
1518
+ if (!control.parent || !control || isEmptyInputValue(control.value))
1519
+ return null;
1520
+ if (!MonkeyEcxUtils.isValidUrl(control.value)) {
1521
+ return {
1522
+ url: true
1523
+ };
1524
+ }
1525
+ return null;
1526
+ }
1527
+ function passwordConfirmValidator(control) {
1528
+ if (!control.parent || !control || isEmptyInputValue(control.value))
1529
+ return null;
1530
+ var parent = control.parent;
1531
+ var password = parent.get('password').value;
1532
+ var passwordConfirm = parent.get('passwordConfirm').value;
1533
+ if (!password || !passwordConfirm)
1534
+ return null;
1535
+ if (password === passwordConfirm)
1536
+ return null;
1537
+ return {
1538
+ passwordsNotMatching: true
1539
+ };
1540
+ }
1541
+ function trueValidator(control) {
1542
+ if (!control.parent || !control)
1543
+ return null;
1544
+ if (control && control.value !== false)
1545
+ return null;
1546
+ return {
1547
+ invalidTrue: true
1548
+ };
1549
+ }
1550
+ function comboValidator(control) {
1551
+ if (!control.parent || !control)
1552
+ return null;
1553
+ if (control && control.value !== '0')
1554
+ return null;
1555
+ return {
1556
+ invalidCombo: true
1557
+ };
1558
+ }
1559
+ function zipCodeValidator(control) {
1560
+ if (!control.parent || !control || isEmptyInputValue(control.value))
1561
+ return null;
1562
+ if (control && control.value) {
1563
+ if (!MonkeyEcxUtils.isValidZipCode(control.value)) {
1564
+ return {
1565
+ invalidZipCode: true
1566
+ };
1567
+ }
1568
+ }
1569
+ return null;
1570
+ }
1571
+ function documentValidator(control, country) {
1572
+ if (!control.parent || !control || isEmptyInputValue(control.value))
1573
+ return null;
1574
+ if (country === 'BR') {
1575
+ if (!MonkeyEcxUtils.isCPFCNPJValid(control.value)) {
1576
+ return {
1577
+ invalidCpfCnpj: true
1578
+ };
1579
+ }
1580
+ }
1581
+ else if (country === 'CL') {
1582
+ if (!MonkeyEcxUtils.isValidRUT(control.value)) {
1583
+ return {
1584
+ invalidRut: true
1585
+ };
1586
+ }
1587
+ }
1588
+ return null;
1589
+ }
1590
+ function dateValidator(control) {
1591
+ if (!control.parent || !control || isEmptyInputValue(control.value))
1592
+ return null;
1593
+ var dateFormat = 'MM-DD-YYYY';
1594
+ if (!moment(moment(control.value).format(dateFormat), ['DD/MM/YYYY', 'MM-DD-YYYY', 'YYYY-MM-DD'], true).isValid()) {
1595
+ return {
1596
+ invalidDate: true
1597
+ };
1598
+ }
1599
+ return null;
1600
+ }
1601
+ var Validators = /** @class */ (function () {
1602
+ function Validators() {
1603
+ }
1604
+ Validators.email = function (control) {
1605
+ return emailValidator(control);
1606
+ };
1607
+ Validators.dateRange = function (control) {
1608
+ return dateRangeValidator(control);
1609
+ };
1610
+ Validators.unlockSponsorRegister = function (control) {
1611
+ return registerValidator(control, 'sponsor');
1612
+ };
1613
+ Validators.unlockBuyerRegister = function (control) {
1614
+ return registerValidator(control, 'buyer');
1615
+ };
1616
+ Validators.dateStartEnd = function (control) {
1617
+ return dateStartEndValidator(control);
1618
+ };
1619
+ Validators.url = function (control) {
1620
+ return urlValidator(control);
1621
+ };
1622
+ Validators.passwordConfirm = function (control) {
1623
+ return passwordConfirmValidator(control);
1624
+ };
1625
+ Validators.true = function (control) {
1626
+ return trueValidator(control);
1627
+ };
1628
+ Validators.combo = function (control) {
1629
+ return comboValidator(control);
1630
+ };
1631
+ Validators.zipCode = function (control) {
1632
+ return zipCodeValidator(control);
1633
+ };
1634
+ Validators.documentBR = function (control) {
1635
+ return documentValidator(control, 'BR');
1636
+ };
1637
+ Validators.documentCL = function (control) {
1638
+ return documentValidator(control, 'CL');
1639
+ };
1640
+ Validators.date = function (control) {
1641
+ return dateValidator(control);
1642
+ };
1643
+ return Validators;
1644
+ }());
1645
+
1451
1646
  /* eslint-disable object-curly-newline */
1452
1647
 
1453
1648
  function MonkeyEcxCoreServiceConstructor() {
@@ -4320,8 +4515,20 @@
4320
4515
  exports.MonkeyFrontCoreModuleModule = MonkeyFrontCoreModuleModule;
4321
4516
  exports.Statics = statics;
4322
4517
  exports.ValidateUtils = validateUtils;
4518
+ exports.Validators = Validators;
4323
4519
  exports.VersionChangedComponent = VersionChangedComponent;
4324
4520
  exports.VersionChangedModule = VersionChangedModule;
4521
+ exports.comboValidator = comboValidator;
4522
+ exports.dateRangeValidator = dateRangeValidator;
4523
+ exports.dateStartEndValidator = dateStartEndValidator;
4524
+ exports.dateValidator = dateValidator;
4525
+ exports.documentValidator = documentValidator;
4526
+ exports.emailValidator = emailValidator;
4527
+ exports.passwordConfirmValidator = passwordConfirmValidator;
4528
+ exports.registerValidator = registerValidator;
4529
+ exports.trueValidator = trueValidator;
4530
+ exports.urlValidator = urlValidator;
4531
+ exports.zipCodeValidator = zipCodeValidator;
4325
4532
 
4326
4533
  Object.defineProperty(exports, '__esModule', { value: true });
4327
4534