@carecard/validate 3.0.4 → 3.0.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/index.d.ts +90 -62
- package/index.js +7 -2
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -1,68 +1,96 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Utility
|
|
2
|
+
* Utility function to validate multiple properties of an object at once.
|
|
3
3
|
*/
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
4
|
+
export function validateProperties(obj?: Record<string, any>): Record<string, any>;
|
|
5
|
+
|
|
6
|
+
/** Checks if the string is a valid image URL format. */
|
|
7
|
+
export function isImageUrl(imageUrl: any): boolean;
|
|
8
|
+
/** Checks if the value is an integer. */
|
|
9
|
+
export function isInteger(number: any): boolean;
|
|
10
|
+
/** Checks if the string is a valid JSON string and can be parsed into an object. */
|
|
11
|
+
export function isValidJsonString(str: any): boolean;
|
|
12
|
+
/** Checks if the string represents a valid integer. */
|
|
13
|
+
export function isValidIntegerString(str: any): boolean;
|
|
14
|
+
/** Checks if the string is a valid UUID. */
|
|
15
|
+
export function isValidUuidString(str: any): boolean;
|
|
16
|
+
/** Checks if the string contains only alphanumeric characters, spaces, underscores, or hyphens. */
|
|
17
|
+
export function isCharactersString(str: any): boolean;
|
|
18
|
+
/** Checks if the string is a valid name format. */
|
|
19
|
+
export function isNameString(str: any): boolean;
|
|
20
|
+
/** Checks if the string is safe for search queries. */
|
|
21
|
+
export function isSafeSearchString(str: any): boolean;
|
|
22
|
+
/** Checks if the string is a valid email address. */
|
|
23
|
+
export function isEmailString(email: any): boolean;
|
|
24
|
+
/** Checks if the string is a valid JWT format. */
|
|
25
|
+
export function isJwtString(jwt: any): boolean;
|
|
26
|
+
/** Checks if the string is a valid strong password. */
|
|
27
|
+
export function isPasswordString(password: any): boolean;
|
|
28
|
+
/** Checks if the string is a valid simple password. */
|
|
29
|
+
export function isSimplePasswordString(password: any): boolean;
|
|
30
|
+
/** Returns a failure message if the password is not strong enough. */
|
|
31
|
+
export function isPasswordStringFailureMessage(password: any): string | null;
|
|
32
|
+
/** Returns a failure message if the password is not valid as a simple password. */
|
|
33
|
+
export function isSimplePasswordStringFailureMessage(password: any): string | null;
|
|
34
|
+
/** Checks if the string is a valid username. */
|
|
35
|
+
export function isUsernameString(str: any): boolean;
|
|
36
|
+
/** Checks if the string is a valid phone number. */
|
|
37
|
+
export function isPhoneNumber(str: any): boolean;
|
|
38
|
+
/** Checks if the string is URL-safe. */
|
|
39
|
+
export function isUrlSafeString(inputString: any): boolean;
|
|
40
|
+
/** Checks if the string length is between 6 and 24 characters. */
|
|
41
|
+
export function isString6To24CharacterLong(password: any): boolean;
|
|
42
|
+
/** Checks if the string length is between 6 and 16 characters. */
|
|
43
|
+
export function isString6To16CharacterLong(password: any): boolean;
|
|
44
|
+
/** Checks if the string is a valid Canadian province abbreviation (ON, QC). */
|
|
45
|
+
export function isProvinceString(inputString: any): boolean;
|
|
46
|
+
/** Checks if the value is a boolean. */
|
|
47
|
+
export function isBoolValue(inputValue: any): boolean;
|
|
48
|
+
/** Checks if the string is a valid Canadian postal code. */
|
|
49
|
+
export function isPostalCodeString(inputString: any): boolean;
|
|
50
|
+
/** Checks if the string contains only allowed "safe" characters. */
|
|
51
|
+
export function isSafeString(str: any): boolean;
|
|
52
|
+
/** Checks if a string exists within a given array of strings (case-insensitive). */
|
|
53
|
+
export function isInStringArray(StringArray: string[], inputString: any): boolean;
|
|
54
|
+
/** Checks if the string is a valid country code (e.g., +1). */
|
|
55
|
+
export function isCountryCodeString(str: any): boolean;
|
|
56
|
+
/** Checks if the string is a valid domain name. */
|
|
57
|
+
export function isValidDomainName(domain: any): boolean;
|
|
58
|
+
/** Checks if the string is a valid ISO 8601 timestamp with time zone. */
|
|
59
|
+
export function isValidTimestampzString(str: any): boolean;
|
|
60
|
+
/** Checks if the string is a valid ISO 8601 timestamp without time zone. */
|
|
61
|
+
export function isValidTimestampString(str: any): boolean;
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
|
-
* Utility
|
|
64
|
+
* Utility functions for validating various types of strings and values.
|
|
65
|
+
* @deprecated Use direct imports instead.
|
|
65
66
|
*/
|
|
66
|
-
export const
|
|
67
|
-
|
|
67
|
+
export const validate: {
|
|
68
|
+
isImageUrl: typeof isImageUrl;
|
|
69
|
+
isInteger: typeof isInteger;
|
|
70
|
+
isValidJsonString: typeof isValidJsonString;
|
|
71
|
+
isValidIntegerString: typeof isValidIntegerString;
|
|
72
|
+
isValidUuidString: typeof isValidUuidString;
|
|
73
|
+
isCharactersString: typeof isCharactersString;
|
|
74
|
+
isNameString: typeof isNameString;
|
|
75
|
+
isSafeSearchString: typeof isSafeSearchString;
|
|
76
|
+
isEmailString: typeof isEmailString;
|
|
77
|
+
isJwtString: typeof isJwtString;
|
|
78
|
+
isPasswordString: typeof isPasswordString;
|
|
79
|
+
isSimplePasswordString: typeof isSimplePasswordString;
|
|
80
|
+
isPasswordStringFailureMessage: typeof isPasswordStringFailureMessage;
|
|
81
|
+
isSimplePasswordStringFailureMessage: typeof isSimplePasswordStringFailureMessage;
|
|
82
|
+
isUsernameString: typeof isUsernameString;
|
|
83
|
+
isPhoneNumber: typeof isPhoneNumber;
|
|
84
|
+
isUrlSafeString: typeof isUrlSafeString;
|
|
85
|
+
isString6To24CharacterLong: typeof isString6To24CharacterLong;
|
|
86
|
+
isString6To16CharacterLong: typeof isString6To16CharacterLong;
|
|
87
|
+
isProvinceString: typeof isProvinceString;
|
|
88
|
+
isBoolValue: typeof isBoolValue;
|
|
89
|
+
isPostalCodeString: typeof isPostalCodeString;
|
|
90
|
+
isSafeString: typeof isSafeString;
|
|
91
|
+
isInStringArray: typeof isInStringArray;
|
|
92
|
+
isCountryCodeString: typeof isCountryCodeString;
|
|
93
|
+
isValidDomainName: typeof isValidDomainName;
|
|
94
|
+
isValidTimestampzString: typeof isValidTimestampzString;
|
|
95
|
+
isValidTimestampString: typeof isValidTimestampString;
|
|
68
96
|
};
|
package/index.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
+
const validate = require( './lib/validate' );
|
|
2
|
+
const validateProperties = require( './lib/validateProperties' );
|
|
3
|
+
|
|
1
4
|
module.exports = {
|
|
2
|
-
validate
|
|
3
|
-
validateProperties
|
|
5
|
+
validate,
|
|
6
|
+
validateProperties,
|
|
7
|
+
...validate,
|
|
8
|
+
...validateProperties
|
|
4
9
|
}
|