@dreyyan/toolkit 1.0.11 → 1.0.12

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/dist/index.d.mts CHANGED
@@ -1,8 +1,10 @@
1
- type AuthErrorCode = "EMAIL_REQUIRED" | "EMAIL_INVALID" | "PASSWORD_REQUIRED" | "PASSWORD_TOO_SHORT";
1
+ type AuthErrorCode = "FULL_NAME_REQUIRED" | "EMAIL_REQUIRED" | "EMAIL_INVALID" | "PASSWORD_REQUIRED" | "PASSWORD_TOO_SHORT" | "CONFIRM_PASSWORD_REQUIRED" | "PASSWORDS_DO_NOT_MATCH";
2
2
 
3
3
  declare function validateSignup(input: {
4
+ fullName: string;
4
5
  email: string;
5
6
  password: string;
7
+ confirmPassword: string;
6
8
  }): {
7
9
  ok: boolean;
8
10
  errors: AuthErrorCode[];
package/dist/index.d.ts CHANGED
@@ -1,8 +1,10 @@
1
- type AuthErrorCode = "EMAIL_REQUIRED" | "EMAIL_INVALID" | "PASSWORD_REQUIRED" | "PASSWORD_TOO_SHORT";
1
+ type AuthErrorCode = "FULL_NAME_REQUIRED" | "EMAIL_REQUIRED" | "EMAIL_INVALID" | "PASSWORD_REQUIRED" | "PASSWORD_TOO_SHORT" | "CONFIRM_PASSWORD_REQUIRED" | "PASSWORDS_DO_NOT_MATCH";
2
2
 
3
3
  declare function validateSignup(input: {
4
+ fullName: string;
4
5
  email: string;
5
6
  password: string;
7
+ confirmPassword: string;
6
8
  }): {
7
9
  ok: boolean;
8
10
  errors: AuthErrorCode[];
package/dist/index.js CHANGED
@@ -35,19 +35,36 @@ var isValidEmail = (email) => {
35
35
  // src/auth/signup.validator.ts
36
36
  function validateSignup(input) {
37
37
  const errors = [];
38
- if (!input.email) errors.push("EMAIL_REQUIRED");
39
- else if (!isValidEmail(input.email)) errors.push("EMAIL_INVALID");
40
- if (!input.password) errors.push("PASSWORD_REQUIRED");
41
- else if (input.password.length < 8) errors.push("PASSWORD_TOO_SHORT");
38
+ if (!input.fullName || input.fullName.trim().length === 0) {
39
+ errors.push("FULL_NAME_REQUIRED");
40
+ }
41
+ if (!input.email) {
42
+ errors.push("EMAIL_REQUIRED");
43
+ } else if (!isValidEmail(input.email)) {
44
+ errors.push("EMAIL_INVALID");
45
+ }
46
+ if (!input.password) {
47
+ errors.push("PASSWORD_REQUIRED");
48
+ } else if (input.password.length < 8) {
49
+ errors.push("PASSWORD_TOO_SHORT");
50
+ }
51
+ if (!input.confirmPassword) {
52
+ errors.push("CONFIRM_PASSWORD_REQUIRED");
53
+ } else if (input.password !== input.confirmPassword) {
54
+ errors.push("PASSWORDS_DO_NOT_MATCH");
55
+ }
42
56
  return errors.length ? { ok: false, errors } : { ok: true };
43
57
  }
44
58
 
45
59
  // src/ui-messages/auth.messages.ts
46
60
  var AUTH_MESSAGES = {
61
+ FULL_NAME_REQUIRED: "Full name is required.",
47
62
  EMAIL_REQUIRED: "Email is required.",
48
63
  EMAIL_INVALID: "Please enter a valid email address (e.g. name@example.com).",
49
64
  PASSWORD_REQUIRED: "Password is required.",
50
- PASSWORD_TOO_SHORT: "Password must be at least 8 characters long."
65
+ PASSWORD_TOO_SHORT: "Password must be at least 8 characters long.",
66
+ CONFIRM_PASSWORD_REQUIRED: "Please confirm your password.",
67
+ PASSWORDS_DO_NOT_MATCH: "Passwords do not match."
51
68
  };
52
69
  // Annotate the CommonJS export names for ESM import in node:
53
70
  0 && (module.exports = {
package/dist/index.mjs CHANGED
@@ -7,19 +7,36 @@ var isValidEmail = (email) => {
7
7
  // src/auth/signup.validator.ts
8
8
  function validateSignup(input) {
9
9
  const errors = [];
10
- if (!input.email) errors.push("EMAIL_REQUIRED");
11
- else if (!isValidEmail(input.email)) errors.push("EMAIL_INVALID");
12
- if (!input.password) errors.push("PASSWORD_REQUIRED");
13
- else if (input.password.length < 8) errors.push("PASSWORD_TOO_SHORT");
10
+ if (!input.fullName || input.fullName.trim().length === 0) {
11
+ errors.push("FULL_NAME_REQUIRED");
12
+ }
13
+ if (!input.email) {
14
+ errors.push("EMAIL_REQUIRED");
15
+ } else if (!isValidEmail(input.email)) {
16
+ errors.push("EMAIL_INVALID");
17
+ }
18
+ if (!input.password) {
19
+ errors.push("PASSWORD_REQUIRED");
20
+ } else if (input.password.length < 8) {
21
+ errors.push("PASSWORD_TOO_SHORT");
22
+ }
23
+ if (!input.confirmPassword) {
24
+ errors.push("CONFIRM_PASSWORD_REQUIRED");
25
+ } else if (input.password !== input.confirmPassword) {
26
+ errors.push("PASSWORDS_DO_NOT_MATCH");
27
+ }
14
28
  return errors.length ? { ok: false, errors } : { ok: true };
15
29
  }
16
30
 
17
31
  // src/ui-messages/auth.messages.ts
18
32
  var AUTH_MESSAGES = {
33
+ FULL_NAME_REQUIRED: "Full name is required.",
19
34
  EMAIL_REQUIRED: "Email is required.",
20
35
  EMAIL_INVALID: "Please enter a valid email address (e.g. name@example.com).",
21
36
  PASSWORD_REQUIRED: "Password is required.",
22
- PASSWORD_TOO_SHORT: "Password must be at least 8 characters long."
37
+ PASSWORD_TOO_SHORT: "Password must be at least 8 characters long.",
38
+ CONFIRM_PASSWORD_REQUIRED: "Please confirm your password.",
39
+ PASSWORDS_DO_NOT_MATCH: "Passwords do not match."
23
40
  };
24
41
  export {
25
42
  AUTH_MESSAGES,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dreyyan/toolkit",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",