@stbmoz-onboarding/core 1.1.4 → 1.1.5

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.
package/Dates/dates.js CHANGED
@@ -31,4 +31,51 @@ module.exports.ValidateDate = (values, key, errors, invalidDateMsg) => {
31
31
  } catch (error) {
32
32
  errors[key] = invalidDateMsg
33
33
  }
34
- }
34
+ }
35
+
36
+
37
+ module.exports.isValidRange = (date, rangeLimit) => {
38
+ let today = new Date()
39
+ let dateObj = new Date(date)
40
+ let range = today.getFullYear() - dateObj.getFullYear()
41
+ let m = today.getMonth() - dateObj.getMonth()
42
+ if (m < 0 || (m === 0 && today.getDate() < dateObj.getDate())) {
43
+ range--
44
+ }
45
+
46
+ console.log(range, rangeLimit)
47
+ if (range <= rangeLimit) return true
48
+ }
49
+
50
+
51
+ module.exports.isValidRangeFuture = (date, rangeLimit) => {
52
+ let today = new Date()
53
+ let dateObj = new Date(date)
54
+ let range = dateObj.getFullYear() - today.getFullYear()
55
+ let m = dateObj.getMonth() - today.getMonth()
56
+ if (m < 0 || (m === 0 && today.getDate() < dateObj.getDate())) {
57
+ range--
58
+ }
59
+
60
+ console.log(range, rangeLimit)
61
+ if (range <= rangeLimit) return true
62
+ }
63
+
64
+ module.exports.isInFuture = (date) => {
65
+
66
+ let today = new Date()
67
+ let dateObj = new Date(date)
68
+ if (dateObj <= today) {
69
+ return true
70
+ }
71
+ }
72
+ module.exports.isInPast = (date) => {
73
+
74
+ let today = new Date()
75
+ let dateObj = new Date(date)
76
+ // console.log(dateObj, today)
77
+ if (dateObj >= today) {
78
+ return true
79
+ }
80
+ }
81
+
package/Dates/index.js CHANGED
@@ -1,4 +1,4 @@
1
- const { DateFormater, ValidateDate } = require("./dates")
1
+ const { DateFormater, ValidateDate, isValidRange, isInFuture, isInPast, isValidRangeFuture } = require("./dates")
2
2
 
3
3
 
4
- module.exports = { DateFormater, ValidateDate }
4
+ module.exports = { DateFormater, ValidateDate, isValidRange, isInFuture, isInPast, isValidRangeFuture }
@@ -44,7 +44,7 @@ module.exports.provinces = [
44
44
  {
45
45
  value: "08",
46
46
  default:"40000",
47
- pt: "Zambézia",
47
+ pt: "Zambezia",
48
48
  en: "Zambezia"
49
49
  },
50
50
  {
@@ -1,12 +1,13 @@
1
- const {
2
- isBIValid, isMinor, isPDF, isValidCertificateNumber, isValidNuit,
3
- WordsCount, allowedCharsOnly, containesWhiteSpace, isAboveMaxLength,
4
- isContactValid, isEmailValid, isIn, isInteger, isLength, isMinLength,
5
- isMinValue, isPasswordStrong, isSameAs, startsWith
6
- } = require("./rules")
1
+ const {
2
+ isBIValid, isMinor, isOlder, isPDF, isValidCertificateNumber, isValidNuit,
3
+ WordsCount, allowedCharsOnly, containesWhiteSpace, isAboveMaxLength,
4
+ isContactValid, isEmailValid, isIn, isInteger, isLength, isMinLength,
5
+ isMinValue, isPasswordStrong, isSameAs, startsWith
6
+ } = require("./rules")
7
7
 
8
- module.exports = {
9
- isBIValid, isMinor, isPDF, isValidCertificateNumber, isValidNuit,
10
- WordsCount, allowedCharsOnly, containesWhiteSpace, isAboveMaxLength,
11
- isContactValid, isEmailValid, isIn, isInteger, isLength, isMinLength,
12
- isMinValue, isPasswordStrong, isSameAs, startsWith }
8
+ module.exports = {
9
+ isBIValid, isMinor, isOlder, isPDF, isValidCertificateNumber, isValidNuit,
10
+ WordsCount, allowedCharsOnly, containesWhiteSpace, isAboveMaxLength,
11
+ isContactValid, isEmailValid, isIn, isInteger, isLength, isMinLength,
12
+ isMinValue, isPasswordStrong, isSameAs, startsWith
13
+ }
@@ -142,6 +142,17 @@ module.exports.isMinor = (dateOfBirth, ageLimit) => {
142
142
  if (age >= ageLimit) return true
143
143
  }
144
144
 
145
+ module.exports.isOlder = (dateOfBirth, ageLimit) =>{
146
+ let today = new Date()
147
+ let birthDate = new Date(dateOfBirth)
148
+ let age = today.getFullYear() - birthDate.getFullYear()
149
+ let m = today.getMonth() - birthDate.getMonth()
150
+ if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) {
151
+ age--
152
+ }
153
+ if (age <= ageLimit) return true
154
+ }
155
+
145
156
  module.exports.isBIValid = (BINumber) => {
146
157
  if (/^([0-9]{12})+([A-Z]\b)$/.test(BINumber)) {
147
158
  return true
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- const { DateFormater, ValidateDate } = require("./Dates/dates")
1
+ const { DateFormater, ValidateDate, isValidRange, isInFuture, isInPast, isValidRangeFuture} = require("./Dates/dates")
2
2
  const {
3
3
  AllowedPrefixes, GenerateNumericPin, ReferenceGenerator, Sanitize, Serializer,
4
4
  removeFile, SubArrayGenerator
@@ -20,18 +20,18 @@ const { districts } = require("./Utilities/districts")
20
20
  const { segment, segments } = require("./Utilities/segments")
21
21
  const { AllowedChars } = require("./Utilities/allowedChars")
22
22
  const {
23
- isBIValid, isMinor, isPDF, isValidCertificateNumber, isValidNuit,
23
+ isBIValid, isMinor, isOlder, isPDF, isValidCertificateNumber, isValidNuit,
24
24
  WordsCount, allowedCharsOnly, containesWhiteSpace, isAboveMaxLength,
25
25
  isContactValid, isEmailValid, isIn, isInteger, isLength, isMinLength,
26
26
  isMinValue, isPasswordStrong, isSameAs, startsWith
27
27
  } = require("./Validations/rules")
28
28
 
29
29
  const { branch } = require("./Utilities/branch")
30
- const { incomeFrequecies} = require("./Utilities/incomeFrequencies")
30
+ const { incomeFrequecies } = require("./Utilities/incomeFrequencies")
31
31
  const { neighborhood } = require("./Utilities/neighborhood")
32
32
 
33
33
 
34
- module.exports.Dates = { DateFormater, ValidateDate }
34
+ module.exports.Dates = { DateFormater, ValidateDate, isValidRange, isInFuture, isInPast,isValidRangeFuture }
35
35
 
36
36
  module.exports.Functions = {
37
37
  AllowedPrefixes, GenerateNumericPin, ReferenceGenerator, Sanitize, Serializer, removeFile,
@@ -46,7 +46,7 @@ module.exports.Utilities = {
46
46
  }
47
47
 
48
48
  module.exports.Validations = {
49
- isBIValid, isMinor, isPDF, isValidCertificateNumber, isValidNuit,
49
+ isBIValid, isMinor, isOlder, isPDF, isValidCertificateNumber, isValidNuit,
50
50
  WordsCount, allowedCharsOnly, containesWhiteSpace, isAboveMaxLength,
51
51
  isContactValid, isEmailValid, isIn, isInteger, isLength, isMinLength,
52
52
  isMinValue, isPasswordStrong, isSameAs, startsWith
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "_args": [
3
3
  [
4
- "@stbmoz-onboarding/core@1.1.44",
4
+ "@stbmoz-onboarding/core@1.1.5",
5
5
  "/Users/pedrodava/Desktop/Bank/RAO/frontend"
6
6
  ]
7
7
  ],
8
- "_from": "@stbmoz-onboarding/core@^1.1.4",
9
- "_id": "@stbmoz-onboarding/core@1.1.4",
8
+ "_from": "@stbmoz-onboarding/core@^1.1.5",
9
+ "_id": "@stbmoz-onboarding/core@1.1.5",
10
10
  "_inBundle": false,
11
11
  "_integrity": "sha512-49Uu6x1QbTWFMWRZQz1A28IjRmo8hA22izluXc5Y2yiDii51nvRvLj/Hu3AjGOYvHlWa+j8J1nVh0fmt93WCnA==",
12
12
  "_location": "/@stbmoz-onboarding/core",
@@ -14,21 +14,21 @@
14
14
  "_requested": {
15
15
  "type": "range",
16
16
  "registry": true,
17
- "raw": "@stbmoz-onboarding/core@^1.1.4",
17
+ "raw": "@stbmoz-onboarding/core@^1.1.5",
18
18
  "name": "@stbmoz-onboarding/core",
19
19
  "escapedName": "@stbmoz-onboarding%2fcore",
20
20
  "scope": "@stbmoz-onboarding",
21
- "rawSpec": "^1.1.4",
21
+ "rawSpec": "^1.1.5",
22
22
  "saveSpec": null,
23
- "fetchSpec": "^1.1.4"
23
+ "fetchSpec": "^1.1.5"
24
24
  },
25
25
  "_requiredBy": [
26
26
  "#USER",
27
27
  "/"
28
28
  ],
29
- "_resolved": "https://registry.npmjs.org/@stbmoz-onboarding/core/-/core-1.1.4.tgz",
29
+ "_resolved": "https://registry.npmjs.org/@stbmoz-onboarding/core/-/core-1.1.5.tgz",
30
30
  "_shasum": "87974a4970b4ae2a12a290bb2ab0d415aab344d1",
31
- "_spec": "@stbmoz-onboarding/core@^1.1.4",
31
+ "_spec": "@stbmoz-onboarding/core@^1.1.5",
32
32
  "_where": "/Users/pedrodava/Desktop/Bank/RAO/frontend",
33
33
  "author": "",
34
34
  "bundleDependencies": false,
@@ -42,5 +42,5 @@
42
42
  "test": "echo \"Error: no test specified\" && exit 1"
43
43
  },
44
44
  "type": "commonjs",
45
- "version": "1.1.4"
45
+ "version": "1.1.5"
46
46
  }