use-password-policy 1.0.1 → 1.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.
package/README.md CHANGED
@@ -19,7 +19,7 @@ Usage:
19
19
 
20
20
  ```javascript
21
21
 
22
- import { usePasswordPolicy } from './usePasswordPolicy';
22
+ import { usePasswordPolicy } from './use-password-policy';
23
23
  function MyComponent() {
24
24
  const [password, setPassword] = useState('');
25
25
  const policy = usePasswordPolicy({
package/Type.ts ADDED
@@ -0,0 +1,10 @@
1
+ export interface CustomPolicy {
2
+ name: string; // Name of the policy (e.g., "SymbolCheck")
3
+ regex?: RegExp; // Regular expression for the check (optional)
4
+ checkFunction?: (password: string) => boolean; // Custom check function (optional)
5
+ message?: string; // Error message if the check fails (optional)
6
+ }
7
+
8
+ export interface StateObjects {
9
+ [key: string]: boolean;
10
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "use-password-policy",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "",
5
5
  "main": "use-password-policy.ts",
6
6
  "scripts": {
@@ -1,5 +1,6 @@
1
1
  import { useState, useEffect, useMemo } from "react";
2
- import { CustomPolicy } from "../App";
2
+ import { CustomPolicy, StateObjects } from "./Type";
3
+
3
4
 
4
5
  export const usePasswordPolicy = ({
5
6
  password,
@@ -33,7 +34,7 @@ export const usePasswordPolicy = ({
33
34
  }
34
35
  }
35
36
 
36
- const [policy, setPolicy] = useState<{ [key: string]: boolean }>(() => {
37
+ const [policy, setPolicy] = useState<StateObjects>(() => {
37
38
  if (useDefaultConfig) {
38
39
  return {
39
40
  caseCheck: false,
@@ -62,7 +63,7 @@ export const usePasswordPolicy = ({
62
63
  });
63
64
 
64
65
  const evaluateChecks = () => {
65
- const newPolicy: { [key: string]: boolean } = { ...policy };
66
+ const newPolicy: StateObjects = { ...policy };
66
67
  if (useDefaultConfig) {
67
68
  newPolicy.caseCheck =
68
69
  merged.caseCheck && RegExp(merged.uppercaseCharRegex).test(password);