@carecard/validate-ts 2.0.1 → 2.0.3

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.
@@ -44,8 +44,9 @@ const isCharactersString = (str) => {
44
44
  };
45
45
  exports.isCharactersString = isCharactersString;
46
46
  const isNameString = (str) => {
47
- if (str === undefined || typeof str !== 'string' || str.length === 0)
47
+ if (str === undefined || typeof str !== 'string' || str.length === 0 || str.length > 1000) {
48
48
  return false;
49
+ }
49
50
  return /^[A-Za-z][0-9a-zA-Z-_.,'() ]+$/.test(str.trim());
50
51
  };
51
52
  exports.isNameString = isNameString;
@@ -56,8 +57,12 @@ const isSafeSearchString = (str) => {
56
57
  };
57
58
  exports.isSafeSearchString = isSafeSearchString;
58
59
  const isEmailString = (email) => {
59
- if (email === undefined || typeof email !== 'string' || email.length === 0)
60
+ if (email === undefined ||
61
+ typeof email !== 'string' ||
62
+ email.length === 0 ||
63
+ email.length > 1000) {
60
64
  return false;
65
+ }
61
66
  const regExpEmail = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
62
67
  return regExpEmail.test(String(email).toLowerCase());
63
68
  };
@@ -102,7 +107,7 @@ const isSimplePasswordStringFailureMessage = (password) => {
102
107
  };
103
108
  exports.isSimplePasswordStringFailureMessage = isSimplePasswordStringFailureMessage;
104
109
  const isUsernameString = (str) => {
105
- if (str === undefined || typeof str !== 'string' || str.length === 0)
110
+ if (str === undefined || typeof str !== 'string' || str.length === 0 || str.length > 200)
106
111
  return false;
107
112
  return /^[0-9a-zA-Z]+$/.test(str);
108
113
  };
@@ -34,8 +34,9 @@ export const isCharactersString = (str) => {
34
34
  return /^[\da-zA-Z _-]+$/.test(str);
35
35
  };
36
36
  export const isNameString = (str) => {
37
- if (str === undefined || typeof str !== 'string' || str.length === 0)
37
+ if (str === undefined || typeof str !== 'string' || str.length === 0 || str.length > 1000) {
38
38
  return false;
39
+ }
39
40
  return /^[A-Za-z][0-9a-zA-Z-_.,'() ]+$/.test(str.trim());
40
41
  };
41
42
  export const isSafeSearchString = (str) => {
@@ -44,8 +45,12 @@ export const isSafeSearchString = (str) => {
44
45
  return /^[A-Za-z][0-9a-zA-Z\-_.,'()@ ]{1,100}$/.test(str.trim());
45
46
  };
46
47
  export const isEmailString = (email) => {
47
- if (email === undefined || typeof email !== 'string' || email.length === 0)
48
+ if (email === undefined ||
49
+ typeof email !== 'string' ||
50
+ email.length === 0 ||
51
+ email.length > 1000) {
48
52
  return false;
53
+ }
49
54
  const regExpEmail = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
50
55
  return regExpEmail.test(String(email).toLowerCase());
51
56
  };
@@ -84,7 +89,7 @@ export const isSimplePasswordStringFailureMessage = (password) => {
84
89
  }
85
90
  };
86
91
  export const isUsernameString = (str) => {
87
- if (str === undefined || typeof str !== 'string' || str.length === 0)
92
+ if (str === undefined || typeof str !== 'string' || str.length === 0 || str.length > 200)
88
93
  return false;
89
94
  return /^[0-9a-zA-Z]+$/.test(str);
90
95
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carecard/validate-ts",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "private": false,
5
5
  "description": "Validate functions",
6
6
  "license": "ISC",
@@ -38,12 +38,13 @@
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/jest": "30.0.0",
41
+ "@types/node": "25.0.3",
42
+ "eslint": "9.39.2",
43
+ "husky": "9.1.7",
41
44
  "jest": "30.2.0",
45
+ "prettier": "3.7.4",
42
46
  "ts-jest": "29.4.6",
43
47
  "typescript": "5.9.3",
44
- "typescript-eslint": "8.50.1",
45
- "prettier": "3.7.4",
46
- "eslint": "9.39.2",
47
- "husky": "9.1.7"
48
+ "typescript-eslint": "8.50.1"
48
49
  }
49
50
  }