@decaf-ts/decorator-validation 1.19.0 → 1.21.0

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.
Files changed (168) hide show
  1. package/lib/cjs/index.cjs +1 -1
  2. package/lib/esm/index.js +1 -1
  3. package/lib/types/constants/index.d.cts +2 -2
  4. package/lib/types/constants/index.d.mts +2 -2
  5. package/lib/types/index.d.cts +7 -7
  6. package/lib/types/index.d.mts +7 -7
  7. package/lib/types/model/Builder.d.cts +3 -3
  8. package/lib/types/model/Builder.d.mts +3 -3
  9. package/lib/types/model/Model.d.cts +4 -4
  10. package/lib/types/model/Model.d.mts +4 -4
  11. package/lib/types/model/ModelErrorDefinition.d.cts +1 -1
  12. package/lib/types/model/ModelErrorDefinition.d.mts +1 -1
  13. package/lib/types/model/ModelRegistry.d.cts +3 -3
  14. package/lib/types/model/ModelRegistry.d.mts +3 -3
  15. package/lib/types/model/construction.d.cts +1 -1
  16. package/lib/types/model/construction.d.mts +1 -1
  17. package/lib/types/model/index.d.cts +10 -10
  18. package/lib/types/model/index.d.mts +10 -10
  19. package/lib/types/model/types.d.cts +3 -3
  20. package/lib/types/model/types.d.mts +3 -3
  21. package/lib/types/model/utils.d.cts +1 -1
  22. package/lib/types/model/utils.d.mts +1 -1
  23. package/lib/types/model/validation.d.cts +3 -3
  24. package/lib/types/model/validation.d.mts +3 -3
  25. package/lib/types/overrides/Metadata.d.cts +3 -3
  26. package/lib/types/overrides/Metadata.d.mts +3 -3
  27. package/lib/types/overrides/index.d.cts +3 -3
  28. package/lib/types/overrides/index.d.mts +3 -3
  29. package/lib/types/overrides/types.d.cts +1 -1
  30. package/lib/types/overrides/types.d.mts +1 -1
  31. package/lib/types/types/index.d.cts +1 -1
  32. package/lib/types/types/index.d.mts +1 -1
  33. package/lib/types/types/validation.d.cts +2 -2
  34. package/lib/types/types/validation.d.mts +2 -2
  35. package/lib/types/utils/index.d.cts +11 -11
  36. package/lib/types/utils/index.d.mts +11 -11
  37. package/lib/types/utils/serialization.d.cts +1 -1
  38. package/lib/types/utils/serialization.d.mts +1 -1
  39. package/lib/types/utils/serializers.d.cts +2 -2
  40. package/lib/types/utils/serializers.d.mts +2 -2
  41. package/lib/types/utils/types.d.cts +1 -1
  42. package/lib/types/utils/types.d.mts +1 -1
  43. package/lib/types/validation/Validation.d.cts +2 -2
  44. package/lib/types/validation/Validation.d.mts +2 -2
  45. package/lib/types/validation/Validators/AsyncValidator.d.cts +3 -3
  46. package/lib/types/validation/Validators/AsyncValidator.d.mts +3 -3
  47. package/lib/types/validation/Validators/BaseValidator.d.cts +3 -3
  48. package/lib/types/validation/Validators/BaseValidator.d.mts +3 -3
  49. package/lib/types/validation/Validators/DateValidator.d.cts +2 -2
  50. package/lib/types/validation/Validators/DateValidator.d.mts +2 -2
  51. package/lib/types/validation/Validators/DiffValidator.d.cts +3 -3
  52. package/lib/types/validation/Validators/DiffValidator.d.mts +3 -3
  53. package/lib/types/validation/Validators/EmailValidator.d.cts +2 -2
  54. package/lib/types/validation/Validators/EmailValidator.d.mts +2 -2
  55. package/lib/types/validation/Validators/EqualsValidator.d.cts +3 -3
  56. package/lib/types/validation/Validators/EqualsValidator.d.mts +3 -3
  57. package/lib/types/validation/Validators/GreaterThanOrEqualValidator.d.cts +3 -3
  58. package/lib/types/validation/Validators/GreaterThanOrEqualValidator.d.mts +3 -3
  59. package/lib/types/validation/Validators/GreaterThanValidator.d.cts +3 -3
  60. package/lib/types/validation/Validators/GreaterThanValidator.d.mts +3 -3
  61. package/lib/types/validation/Validators/LessThanOrEqualValidator.d.cts +3 -3
  62. package/lib/types/validation/Validators/LessThanOrEqualValidator.d.mts +3 -3
  63. package/lib/types/validation/Validators/LessThanValidator.d.cts +3 -3
  64. package/lib/types/validation/Validators/LessThanValidator.d.mts +3 -3
  65. package/lib/types/validation/Validators/ListValidator.d.cts +2 -2
  66. package/lib/types/validation/Validators/ListValidator.d.mts +2 -2
  67. package/lib/types/validation/Validators/MaxLengthValidator.d.cts +2 -2
  68. package/lib/types/validation/Validators/MaxLengthValidator.d.mts +2 -2
  69. package/lib/types/validation/Validators/MaxValidator.d.cts +2 -2
  70. package/lib/types/validation/Validators/MaxValidator.d.mts +2 -2
  71. package/lib/types/validation/Validators/MinLengthValidator.d.cts +2 -2
  72. package/lib/types/validation/Validators/MinLengthValidator.d.mts +2 -2
  73. package/lib/types/validation/Validators/MinValidator.d.cts +2 -2
  74. package/lib/types/validation/Validators/MinValidator.d.mts +2 -2
  75. package/lib/types/validation/Validators/OptionValidator.d.cts +2 -2
  76. package/lib/types/validation/Validators/OptionValidator.d.mts +2 -2
  77. package/lib/types/validation/Validators/PasswordValidator.d.cts +2 -2
  78. package/lib/types/validation/Validators/PasswordValidator.d.mts +2 -2
  79. package/lib/types/validation/Validators/PatternValidator.d.cts +2 -2
  80. package/lib/types/validation/Validators/PatternValidator.d.mts +2 -2
  81. package/lib/types/validation/Validators/RequiredValidator.d.cts +2 -2
  82. package/lib/types/validation/Validators/RequiredValidator.d.mts +2 -2
  83. package/lib/types/validation/Validators/StepValidator.d.cts +2 -2
  84. package/lib/types/validation/Validators/StepValidator.d.mts +2 -2
  85. package/lib/types/validation/Validators/TypeValidator.d.cts +2 -2
  86. package/lib/types/validation/Validators/TypeValidator.d.mts +2 -2
  87. package/lib/types/validation/Validators/URLValidator.d.cts +2 -2
  88. package/lib/types/validation/Validators/URLValidator.d.mts +2 -2
  89. package/lib/types/validation/Validators/Validator.d.cts +3 -3
  90. package/lib/types/validation/Validators/Validator.d.mts +3 -3
  91. package/lib/types/validation/Validators/ValidatorRegistry.d.cts +3 -3
  92. package/lib/types/validation/Validators/ValidatorRegistry.d.mts +3 -3
  93. package/lib/types/validation/Validators/decorators.d.cts +1 -1
  94. package/lib/types/validation/Validators/decorators.d.mts +1 -1
  95. package/lib/types/validation/Validators/index.d.cts +26 -26
  96. package/lib/types/validation/Validators/index.d.mts +26 -26
  97. package/lib/types/validation/decorators.d.cts +2 -2
  98. package/lib/types/validation/decorators.d.mts +2 -2
  99. package/lib/types/validation/index.d.cts +4 -4
  100. package/lib/types/validation/index.d.mts +4 -4
  101. package/lib/types/validation/types.d.cts +2 -2
  102. package/lib/types/validation/types.d.mts +2 -2
  103. package/package.json +1 -1
  104. package/lib/types/constants/errors.d.ts +0 -17
  105. package/lib/types/constants/index.d.ts +0 -2
  106. package/lib/types/constants/validation.d.ts +0 -16
  107. package/lib/types/index.d.ts +0 -20
  108. package/lib/types/model/Builder.d.ts +0 -86
  109. package/lib/types/model/Model.d.ts +0 -286
  110. package/lib/types/model/ModelErrorDefinition.d.ts +0 -22
  111. package/lib/types/model/ModelRegistry.d.ts +0 -181
  112. package/lib/types/model/constants.d.ts +0 -65
  113. package/lib/types/model/construction.d.ts +0 -46
  114. package/lib/types/model/decorators.d.ts +0 -47
  115. package/lib/types/model/index.d.ts +0 -10
  116. package/lib/types/model/types.d.ts +0 -145
  117. package/lib/types/model/utils.d.ts +0 -13
  118. package/lib/types/model/validation.d.ts +0 -92
  119. package/lib/types/overrides/Metadata.d.ts +0 -132
  120. package/lib/types/overrides/index.d.ts +0 -4
  121. package/lib/types/overrides/overrides.d.ts +0 -1
  122. package/lib/types/overrides/types.d.ts +0 -17
  123. package/lib/types/types/index.d.ts +0 -1
  124. package/lib/types/types/validation.d.ts +0 -28
  125. package/lib/types/utils/DateBuilder.d.ts +0 -121
  126. package/lib/types/utils/PathProxy.d.ts +0 -43
  127. package/lib/types/utils/constants.d.ts +0 -32
  128. package/lib/types/utils/dates.d.ts +0 -86
  129. package/lib/types/utils/equality.d.ts +0 -56
  130. package/lib/types/utils/hashing.d.ts +0 -82
  131. package/lib/types/utils/index.d.ts +0 -11
  132. package/lib/types/utils/registry.d.ts +0 -68
  133. package/lib/types/utils/serialization.d.ts +0 -12
  134. package/lib/types/utils/serializers.d.ts +0 -41
  135. package/lib/types/utils/strings.d.ts +0 -25
  136. package/lib/types/utils/types.d.ts +0 -35
  137. package/lib/types/validation/Validation.d.ts +0 -53
  138. package/lib/types/validation/Validators/AsyncValidator.d.ts +0 -72
  139. package/lib/types/validation/Validators/BaseValidator.d.ts +0 -118
  140. package/lib/types/validation/Validators/DateValidator.d.ts +0 -60
  141. package/lib/types/validation/Validators/DiffValidator.d.ts +0 -29
  142. package/lib/types/validation/Validators/EmailValidator.d.ts +0 -60
  143. package/lib/types/validation/Validators/EqualsValidator.d.ts +0 -29
  144. package/lib/types/validation/Validators/GreaterThanOrEqualValidator.d.ts +0 -29
  145. package/lib/types/validation/Validators/GreaterThanValidator.d.ts +0 -29
  146. package/lib/types/validation/Validators/LessThanOrEqualValidator.d.ts +0 -29
  147. package/lib/types/validation/Validators/LessThanValidator.d.ts +0 -29
  148. package/lib/types/validation/Validators/ListValidator.d.ts +0 -66
  149. package/lib/types/validation/Validators/MaxLengthValidator.d.ts +0 -29
  150. package/lib/types/validation/Validators/MaxValidator.d.ts +0 -74
  151. package/lib/types/validation/Validators/MinLengthValidator.d.ts +0 -29
  152. package/lib/types/validation/Validators/MinValidator.d.ts +0 -74
  153. package/lib/types/validation/Validators/OptionValidator.d.ts +0 -29
  154. package/lib/types/validation/Validators/PasswordValidator.d.ts +0 -28
  155. package/lib/types/validation/Validators/PatternValidator.d.ts +0 -103
  156. package/lib/types/validation/Validators/RequiredValidator.d.ts +0 -74
  157. package/lib/types/validation/Validators/StepValidator.d.ts +0 -29
  158. package/lib/types/validation/Validators/TypeValidator.d.ts +0 -79
  159. package/lib/types/validation/Validators/URLValidator.d.ts +0 -61
  160. package/lib/types/validation/Validators/Validator.d.ts +0 -65
  161. package/lib/types/validation/Validators/ValidatorRegistry.d.ts +0 -41
  162. package/lib/types/validation/Validators/constants.d.ts +0 -157
  163. package/lib/types/validation/Validators/decorators.d.ts +0 -12
  164. package/lib/types/validation/Validators/index.d.ts +0 -26
  165. package/lib/types/validation/Validators/utils.d.ts +0 -75
  166. package/lib/types/validation/decorators.d.ts +0 -313
  167. package/lib/types/validation/index.d.ts +0 -9
  168. package/lib/types/validation/types.d.ts +0 -309
@@ -1,157 +0,0 @@
1
- /**
2
- * @description Object-like set of keys used for comparison-based validations.
3
- * @summary Provides canonical names for validators that compare two values (equality and ordering checks).
4
- * @typedef {Object} ComparisonValidationKeysDef
5
- * @property {"equals"} EQUALS Validates if two values are equal.
6
- * @property {"different"} DIFF Validates if two values are different.
7
- * @property {"lessThan"} LESS_THAN Validates if a value is less than another.
8
- * @property {"lessThanOrEqual"} LESS_THAN_OR_EQUAL Validates if a value is less than or equal to another.
9
- * @property {"greaterThan"} GREATER_THAN Validates if a value is greater than another.
10
- * @property {"greaterThanOrEqual"} GREATER_THAN_OR_EQUAL Validates if a value is greater than or equal to another.
11
- * @memberOf module:decorator-validation.Validation
12
- */
13
- /**
14
- * @description Keys used for comparison-based validations.
15
- * @summary Canonical key names for comparison validators.
16
- * @const ComparisonValidationKeys
17
- * @memberOf module:decorator-validation.Validation
18
- * @category Validation
19
- * @type {ComparisonValidationKeysDef}
20
- */
21
- export declare const ComparisonValidationKeys: {
22
- readonly EQUALS: "equals";
23
- readonly DIFF: "different";
24
- readonly LESS_THAN: "lessThan";
25
- readonly LESS_THAN_OR_EQUAL: "lessThanOrEqual";
26
- readonly GREATER_THAN: "greaterThan";
27
- readonly GREATER_THAN_OR_EQUAL: "greaterThanOrEqual";
28
- };
29
- /**
30
- * @description Object-like set of keys used across all validators in the system.
31
- * @summary Defines the canonical namespaced key prefix and the individual validation flags for rules such as required, min/max, length, patterns, types, lists and more.
32
- * @typedef {Object} ValidationKeysDef
33
- * @property {string} REFLECT prefixes others (namespace prefix)
34
- * @property {"required"} REQUIRED sets as required
35
- * @property {"min"} MIN defines min value
36
- * @property {"max"} MAX defines max value
37
- * @property {"step"} STEP defines step
38
- * @property {"minlength"} MIN_LENGTH defines min length
39
- * @property {"maxlength"} MAX_LENGTH defines max length
40
- * @property {"pattern"} PATTERN defines pattern
41
- * @property {"email"} EMAIL defines email
42
- * @property {"url"} URL defines url
43
- * @property {"date"} DATE defines date
44
- * @property {"type"} TYPE defines type
45
- * @property {"password"} PASSWORD defines password
46
- * @property {"list"} LIST defines list
47
- * @property {"unique"} UNIQUE flags uniqueness
48
- * @property {"validator"} VALIDATOR custom validator id
49
- * @memberOf module:decorator-validation.Validation
50
- */
51
- /**
52
- * @description The keys used for validation.
53
- * @summary A namespaced collection of validation key strings used throughout the library.
54
- * @const ValidationKeys
55
- * @memberOf module:decorator-validation.Validation
56
- * @category Validation
57
- * @type {ValidationKeysDef}
58
- */
59
- export declare const ValidationKeys: {
60
- readonly EQUALS: "equals";
61
- readonly DIFF: "different";
62
- readonly LESS_THAN: "lessThan";
63
- readonly LESS_THAN_OR_EQUAL: "lessThanOrEqual";
64
- readonly GREATER_THAN: "greaterThan";
65
- readonly GREATER_THAN_OR_EQUAL: "greaterThanOrEqual";
66
- readonly REFLECT: "validation";
67
- readonly DATE: "date";
68
- readonly EMAIL: "email";
69
- readonly FORMAT: "format";
70
- readonly LIST: "list";
71
- readonly MAX: "max";
72
- readonly MAX_LENGTH: "maxlength";
73
- readonly MIN: "min";
74
- readonly MIN_LENGTH: "minlength";
75
- readonly PASSWORD: "password";
76
- readonly PATTERN: "pattern";
77
- readonly REQUIRED: "required";
78
- readonly STEP: "step";
79
- readonly TYPE: "type";
80
- readonly UNIQUE: "unique";
81
- readonly URL: "url";
82
- readonly VALIDATOR: "validator";
83
- readonly ENUM: "enum";
84
- };
85
- /**
86
- * @description list of month names
87
- * @summary Stores month names. Can be changed for localization purposes
88
- * @const MONTH_NAMES
89
- * @memberOf module:decorator-validation.Validation
90
- * @category Validation
91
- */
92
- export declare const MONTH_NAMES: string[];
93
- /**
94
- * @description list of names of days of the week
95
- * @summary Stores names for days of the week. Can be changed for localization purposes
96
- * @const DAYS_OF_WEEK_NAMES
97
- * @memberOf module:decorator-validation.Validation
98
- * @category Validation
99
- */
100
- export declare const DAYS_OF_WEEK_NAMES: string[];
101
- /**
102
- * @description Type definition for default error message strings keyed by validation type.
103
- * @summary Enumerates the supported error message keys with their intended meaning; used to localize or override default messages.
104
- * @typedef {Object} DefaultErrorMessages
105
- * @property {string} REQUIRED default error message
106
- * @property {string} MIN default error message
107
- * @property {string} MAX default error message
108
- * @property {string} MIN_LENGTH default error message
109
- * @property {string} MAX_LENGTH default error message
110
- * @property {string} PATTERN default error message
111
- * @property {string} EMAIL default error message
112
- * @property {string} URL default error message
113
- * @property {string} TYPE default error message
114
- * @property {string} STEP default error message
115
- * @property {string} DATE default error message
116
- * @property {string} DEFAULT default error message
117
- * @property {string} PASSWORD default error message
118
- * @property {string} LIST default error message
119
- * @property {string} LIST_INSIDE default error message
120
- * @property {string} MODEL_NOT_FOUND default error message
121
- * @memberOf module:decorator-validation.Validation
122
- */
123
- /**
124
- * @description Defines the default error messages
125
- * @summary Mapping between validation keys and their default human-readable error messages.
126
- * @const DEFAULT_ERROR_MESSAGES
127
- * @memberOf module:decorator-validation.Validation
128
- * @category Validation
129
- * @type {DefaultErrorMessages}
130
- */
131
- export declare const DEFAULT_ERROR_MESSAGES: Record<string, string>;
132
- /**
133
- * @description Type definition for default regular expression patterns used in validation.
134
- * @summary Captures common regex patterns for email, URL, and password policies, including nested grouping for password-related rules.
135
- * @typedef {Object} DefaultPatterns
136
- * @property {RegExp} EMAIL Email address validation pattern
137
- * @property {RegExp} URL URL validation pattern
138
- * @property {Object} PASSWORD Password-related regex patterns
139
- * @property {RegExp} PASSWORD.CHAR8_ONE_OF_EACH At least 8 chars with lower, upper, number, and special char
140
- * @memberOf module:decorator-validation.Validation
141
- */
142
- /**
143
- * @description Defines the various default regexp patterns used
144
- * @summary Collection of frequently used validation patterns grouped under semantic keys.
145
- * @const DEFAULT_PATTERNS
146
- * @memberOf module:decorator-validation.Validation
147
- * @category Validation
148
- * @type {DefaultPatterns}
149
- */
150
- export declare const DEFAULT_PATTERNS: {
151
- EMAIL: RegExp;
152
- URL: RegExp;
153
- PASSWORD: {
154
- CHAR8_ONE_OF_EACH: RegExp;
155
- };
156
- asd: string;
157
- };
@@ -1,12 +0,0 @@
1
- import { Validator } from "./Validator";
2
- /**
3
- * @summary Marks the class as a validator for a certain key.
4
- * @description Registers the class in the {@link Validation} with the provided key
5
- *
6
- * @param {string} keys the validation key
7
- *
8
- * @function validator
9
- *
10
- * @category Class Decorators
11
- */
12
- export declare function validator<T extends Validator>(...keys: string[]): (target: object, propertyKey?: string | symbol | unknown, descriptor?: PropertyDescriptor | number) => void;
@@ -1,26 +0,0 @@
1
- export * from "./constants";
2
- export * from "./AsyncValidator";
3
- export * from "./DateValidator";
4
- export * from "./decorators";
5
- export * from "./DiffValidator";
6
- export * from "./EmailValidator";
7
- export * from "./EqualsValidator";
8
- export * from "./GreaterThanValidator";
9
- export * from "./GreaterThanOrEqualValidator";
10
- export * from "./LessThanValidator";
11
- export * from "./LessThanOrEqualValidator";
12
- export * from "./ListValidator";
13
- export * from "./MaxLengthValidator";
14
- export * from "./MaxValidator";
15
- export * from "./MinLengthValidator";
16
- export * from "./MinValidator";
17
- export * from "./OptionValidator";
18
- export * from "./PasswordValidator";
19
- export * from "./PatternValidator";
20
- export * from "./RequiredValidator";
21
- export * from "./StepValidator";
22
- export * from "./TypeValidator";
23
- export * from "./URLValidator";
24
- export * from "./Validator";
25
- export * from "./ValidatorRegistry";
26
- export * from "./utils";
@@ -1,75 +0,0 @@
1
- /**
2
- * Validates whether two values are eligible for comparison using >= or <= operators.
3
- *
4
- * Supported types: `undefined`, `number`, `bigint`, and `Date`.
5
- *
6
- * @param a - The first value to compare.
7
- * @param b - The second value to compare.
8
- *
9
- * @returns {boolean} True if both values are of supported types.
10
- *
11
- * @throws {TypeError} If either value is of an unsupported type.
12
- * @memberOf module:decorator-validation
13
- */
14
- export declare function isValidForGteOrLteComparison(a: any, b: any): boolean;
15
- /**
16
- * @summary Compares two values to determine if the first is less than the second.
17
- * @description Supports numbers and dates. Throws an error for unsupported types.
18
- *
19
- * @param {any} a - The first value to compare.
20
- * @param {any} b - The second value to compare against.
21
- *
22
- * @returns {boolean} True if `a` is less than `b`, false otherwise.
23
- *
24
- * @throws {Error} If either `a` or `b` is `null` or `undefined`.
25
- * @throws {TypeError} If values are of mismatched or unsupported types.
26
- * @memberOf module:decorator-validation
27
- */
28
- export declare function isLessThan(a: any, b: any): boolean;
29
- /**
30
- * Checks if `a` is greater than `b`.
31
- * Supports comparison for numbers and Date objects.
32
- *
33
- * @param {any} a - The value to validate.
34
- * @param {any} b - The value to compare against.
35
- *
36
- * @returns {boolean} True if `a` is greater than `b`, otherwise false.
37
- *
38
- * @throws {Error} If either `a` or `b` is `null` or `undefined`.
39
- * @throws {TypeError} If values are of mismatched or unsupported types.
40
- * @memberOf module:decorator-validation
41
- */
42
- export declare function isGreaterThan(a: any, b: any): boolean;
43
- /**
44
- * @description Checks if a value matches a specified type name
45
- * @summary Utility function to verify if a value's type matches the provided type name
46
- * @param {unknown} value - The value to check the type of
47
- * @param {string} acceptedType - The type name to check against
48
- * @return {boolean} Returns true if the value matches the accepted type, false otherwise
49
- */
50
- export declare function checkType(value: unknown, acceptedType: string): boolean;
51
- /**
52
- * @description Checks if a value matches any of the specified type names
53
- * @summary Utility function to verify if a value's type matches any of the provided type names
54
- * @param {unknown} value - The value to check the type of
55
- * @param {string[]} acceptedTypes - Array of type names to check against
56
- * @return {boolean} Returns true if the value matches any of the accepted types, false otherwise
57
- */
58
- export declare function checkTypes(value: unknown, acceptedTypes: string[]): boolean;
59
- /**
60
- * @description Evaluates if a value matches the specified type metadata
61
- * @summary Compares a value against type metadata to determine if they match
62
- * @param {unknown} value - The value to evaluate
63
- * @param {string | string[] | {name: string}} types - Type metadata to check against, can be a string, array of strings, or an object with a name property
64
- * @return {boolean} Returns true if the value matches the type metadata, false otherwise
65
- */
66
- export declare function evaluateDesignTypes(value: unknown, types: string | string[] | {
67
- name: string;
68
- }): boolean;
69
- /**
70
- * @description Returns the length of a value
71
- * @summary Returns the length of a value
72
- * @param {string | Set<any> | any[] | Map<any, any>} value - The value to evaluate
73
- * @return {number} Returns the length of a value
74
- */
75
- export declare function valueLength(value: string | Set<any> | any[] | Map<any, any>): number;
@@ -1,313 +0,0 @@
1
- import { ComparisonValidatorOptions, DateValidatorOptions, ListValidatorOptions, ValidatorOptions } from "./types";
2
- import { ModelConstructor } from "../model/types";
3
- import { Constructor } from "@decaf-ts/decoration";
4
- /**
5
- * @description Combined property decorator factory for metadata and attribute marking
6
- * @summary Creates a decorator that both marks a property as a model attribute and assigns metadata to it
7
- *
8
- * @template V
9
- * @param {PropertyDecorator} decorator - The metadata key
10
- * @param {string} key - The metadata key
11
- * @param {V} value - The metadata value to associate with the property
12
- * @return {Function} - Combined decorator function
13
- * @function validationMetadata
14
- * @category Property Decorators
15
- */
16
- export declare function validationMetadata<V>(decorator: any, key: string, value: V): (target: object, propertyKey?: string | symbol | unknown, descriptor?: PropertyDescriptor | number) => void;
17
- export declare function innerValidationDecorator(dec: any, key: string, meta: any): (obj: any, prop: any) => void;
18
- export declare function async(): (model: object) => void;
19
- /**
20
- * @description Property decorator that marks a field as required
21
- * @summary Marks the property as required, causing validation to fail if the property is undefined, null, or empty.
22
- * Validators to validate a decorated property must use key {@link ValidationKeys#REQUIRED}.
23
- * This decorator is commonly used as the first validation step for important fields.
24
- *
25
- * @param {string} [message] - The error message to display when validation fails. Defaults to {@link DEFAULT_ERROR_MESSAGES#REQUIRED}
26
- * @return {PropertyDecorator} A decorator function that can be applied to class properties
27
- *
28
- * @function required
29
- * @category Property Decorators
30
- *
31
- * @example
32
- * ```typescript
33
- * class User {
34
- * @required()
35
- * username: string;
36
- *
37
- * @required("Email address is mandatory")
38
- * email: string;
39
- * }
40
- * ```
41
- */
42
- export declare function required(message?: string): (target: any, propertyKey?: any, descriptor?: TypedPropertyDescriptor<any>) => any;
43
- /**
44
- * @description Property decorator that enforces a minimum value constraint
45
- * @summary Defines a minimum value for the property, causing validation to fail if the property value is less than the specified minimum.
46
- * Validators to validate a decorated property must use key {@link ValidationKeys#MIN}.
47
- * This decorator works with numeric values and dates.
48
- *
49
- * @param {number | Date | string} value - The minimum value allowed. For dates, can be a Date object or a string that can be converted to a date
50
- * @param {string} [message] - The error message to display when validation fails. Defaults to {@link DEFAULT_ERROR_MESSAGES#MIN}
51
- * @return {PropertyDecorator} A decorator function that can be applied to class properties
52
- *
53
- * @function min
54
- * @category Property Decorators
55
- *
56
- * @example
57
- * ```typescript
58
- * class Product {
59
- * @min(0)
60
- * price: number;
61
- *
62
- * @min(new Date(2023, 0, 1), "Date must be after January 1, 2023")
63
- * releaseDate: Date;
64
- * }
65
- * ```
66
- */
67
- export declare function min(value: number | Date | string, message?: string): (target: any, propertyKey?: any, descriptor?: TypedPropertyDescriptor<any>) => any;
68
- /**
69
- * @summary Defines a maximum value for the property
70
- * @description Validators to validate a decorated property must use key {@link ValidationKeys#MAX}
71
- *
72
- * @param {number | Date} value
73
- * @param {string} [message] the error message. Defaults to {@link DEFAULT_ERROR_MESSAGES#MAX}
74
- *
75
- * @function max
76
- * @category Property Decorators
77
- */
78
- export declare function max(value: number | Date | string, message?: string): (target: any, propertyKey?: any, descriptor?: TypedPropertyDescriptor<any>) => any;
79
- /**
80
- * @summary Defines a step value for the property
81
- * @description Validators to validate a decorated property must use key {@link ValidationKeys#STEP}
82
- *
83
- * @param {number} value
84
- * @param {string} [message] the error message. Defaults to {@link DEFAULT_ERROR_MESSAGES#STEP}
85
- *
86
- * @function step
87
- * @category Property Decorators
88
- */
89
- export declare function step(value: number, message?: string): (target: any, propertyKey?: any, descriptor?: TypedPropertyDescriptor<any>) => any;
90
- /**
91
- * @summary Defines a minimum length for the property
92
- * @description Validators to validate a decorated property must use key {@link ValidationKeys#MIN_LENGTH}
93
- *
94
- * @param {string} value
95
- * @param {string} [message] the error message. Defaults to {@link DEFAULT_ERROR_MESSAGES#MIN_LENGTH}
96
- *
97
- * @function minlength
98
- * @category Property Decorators
99
- */
100
- export declare function minlength(value: number, message?: string): (target: any, propertyKey?: any, descriptor?: TypedPropertyDescriptor<any>) => any;
101
- /**
102
- * @summary Defines a maximum length for the property
103
- * @description Validators to validate a decorated property must use key {@link ValidationKeys#MAX_LENGTH}
104
- *
105
- * @param {string} value
106
- * @param {string} [message] the error message. Defaults to {@link DEFAULT_ERROR_MESSAGES#MAX_LENGTH}
107
- *
108
- * @function maxlength
109
- * @category Property Decorators
110
- */
111
- export declare function maxlength(value: number, message?: string): (target: any, propertyKey?: any, descriptor?: TypedPropertyDescriptor<any>) => any;
112
- /**
113
- * @summary Defines a RegExp pattern the property must respect
114
- * @description Validators to validate a decorated property must use key {@link ValidationKeys#PATTERN}
115
- *
116
- * @param {string} value
117
- * @param {string} [message] the error message. Defaults to {@link DEFAULT_ERROR_MESSAGES#PATTERN}
118
- *
119
- * @function pattern
120
- * @category Property Decorators
121
- */
122
- export declare function pattern(value: RegExp | string, message?: string): (target: any, propertyKey?: any, descriptor?: TypedPropertyDescriptor<any>) => any;
123
- /**
124
- * @summary Defines the property as an email
125
- * @description Validators to validate a decorated property must use key {@link ValidationKeys#EMAIL}
126
- *
127
- * @param {string} [message] the error message. Defaults to {@link DEFAULT_ERROR_MESSAGES#EMAIL}
128
- *
129
- * @function email
130
- * @category Property Decorators
131
- */
132
- export declare function email(message?: string): (target: any, propertyKey?: any, descriptor?: TypedPropertyDescriptor<any>) => any;
133
- /**
134
- * @summary Defines the property as an URL
135
- * @description Validators to validate a decorated property must use key {@link ValidationKeys#URL}
136
- *
137
- * @param {string} [message] the error message. Defaults to {@link DEFAULT_ERROR_MESSAGES#URL}
138
- *
139
- * @function url
140
- * @category Property Decorators
141
- */
142
- export declare function url(message?: string): (target: any, propertyKey?: any, descriptor?: TypedPropertyDescriptor<any>) => any;
143
- export type TypeConstructor = Constructor | typeof BigInt;
144
- export interface TypeMetadata extends ValidatorOptions {
145
- customTypes: (TypeConstructor | (() => TypeConstructor))[] | TypeConstructor | (() => TypeConstructor);
146
- }
147
- /**
148
- * @summary Enforces type verification
149
- * @description Validators to validate a decorated property must use key {@link ValidationKeys#TYPE}
150
- *
151
- * @param {Constructor[] | Constructor} types accepted types
152
- * @param {Constructor} [message] the error message. Defaults to {@link DEFAULT_ERROR_MESSAGES#TYPE}
153
- *
154
- * @function type
155
- * @category Property Decorators
156
- */
157
- export declare function type(types: (TypeConstructor | (() => TypeConstructor))[] | TypeConstructor | (() => TypeConstructor), message?: string): (target: any, propertyKey?: any, descriptor?: TypedPropertyDescriptor<any>) => any;
158
- export type DateMetadata = DateValidatorOptions;
159
- /**
160
- * @summary Date Handler Decorator
161
- * @description Validators to validate a decorated property must use key {@link ValidationKeys#DATE}
162
- *
163
- * Will enforce serialization according to the selected format
164
- *
165
- * @param {string} format accepted format according to {@link formatDate}
166
- * @param {string} [message] the error message. Defaults to {@link DEFAULT_ERROR_MESSAGES#DATE}
167
- *
168
- * @function date
169
- *
170
- * @category Property Decorators
171
- */
172
- export declare function date(format?: string, message?: string): (target: any, propertyKey?: any, descriptor?: TypedPropertyDescriptor<any>) => any;
173
- /**
174
- * @summary Password Handler Decorator
175
- * @description Validators to validate a decorated property must use key {@link ValidationKeys#PASSWORD}
176
- *
177
- * @param {RegExp} [pattern] defaults to {@link DEFAULT_PATTERNS#CHAR8_ONE_OF_EACH}
178
- * @param {string} [message] the error message. Defaults to {@link DEFAULT_ERROR_MESSAGES#PASSWORD}
179
- *
180
- * @function password
181
- *
182
- * @category Property Decorators
183
- */
184
- export declare function password(pattern?: RegExp, message?: string): (target: any, propertyKey?: any, descriptor?: TypedPropertyDescriptor<any>) => any;
185
- export interface ListMetadata extends ListValidatorOptions {
186
- type: "Array" | "Set";
187
- }
188
- /**
189
- * @summary List Decorator
190
- * @description Also sets the {@link type} to the provided collection
191
- *
192
- * @param {ModelConstructor} clazz
193
- * @param {string} [collection] The collection being used. defaults to Array
194
- * @param {string} [message] defaults to {@link DEFAULT_ERROR_MESSAGES#LIST}
195
- *
196
- * @function list
197
- *
198
- * @category Property Decorators
199
- */
200
- export declare function list(clazz: Constructor | (() => Constructor) | (Constructor | (() => Constructor))[], collection?: "Array" | "Set", message?: string): (target: any, propertyKey?: any, descriptor?: TypedPropertyDescriptor<any>) => any;
201
- /**
202
- * @summary Set Decorator
203
- * @description Wrapper for {@link list} with the 'Set' Collection
204
- *
205
- * @param {ModelConstructor} clazz
206
- * @param {string} [message] defaults to {@link DEFAULT_ERROR_MESSAGES#LIST}
207
- *
208
- * @function set
209
- *
210
- * @category Property Decorators
211
- */
212
- export declare function set(clazz: ModelConstructor<any>, message?: string): (target: any, propertyKey?: any, descriptor?: TypedPropertyDescriptor<any>) => any;
213
- /**
214
- * @summary Declares that the decorated property must be equal to another specified property.
215
- * @description Applies the {@link ValidationKeys.EQUALS} validator to ensure the decorated value matches the value of the given property.
216
- *
217
- * @param {string} propertyToCompare - The name of the property to compare equality against.
218
- * @param {ComparisonValidatorOptions} options - Options for the validator.
219
- * @param {string} [options.label] - The label text displayed in the error message.
220
- * @param {string} [options.message=DEFAULT_ERROR_MESSAGES.EQUALS] - Custom error message to be returned if validation fails.
221
- *
222
- * @returns {PropertyDecorator} A property decorator used to register the equality validation metadata.
223
- *
224
- * @function eq
225
- * @category Property Decorators
226
- */
227
- export declare function eq(propertyToCompare: string, options?: Omit<ComparisonValidatorOptions, "async" | "description">): (obj: any, prop: any) => void;
228
- /**
229
- * @summary Declares that the decorated property must be different from another specified property.
230
- * @description Applies the {@link ValidationKeys.DIFF} validator to ensure the decorated value is different from the value of the given property.
231
- *
232
- * @param {string} propertyToCompare - The name of the property to compare difference against.
233
- * @param {ComparisonValidatorOptions} options - Options for the validator.
234
- * @param {string} [options.label] - The label text displayed in the error message.
235
- * @param {string} [options.message=DEFAULT_ERROR_MESSAGES.DIFF] - Custom error message to be returned if validation fails.
236
- *
237
- * @returns {PropertyDecorator} A property decorator used to register the difference validation metadata.
238
- *
239
- * @function diff
240
- * @category Property Decorators
241
- */
242
- export declare function diff(propertyToCompare: string, options?: Omit<ComparisonValidatorOptions, "async" | "description">): (obj: any, prop: any) => void;
243
- /**
244
- * @summary Declares that the decorated property must be less than another specified property.
245
- * @description Applies the {@link ValidationKeys.LESS_THAN} validator to ensure the decorated value is less than the value of the given property.
246
- *
247
- * @param {string} propertyToCompare - The name of the property to compare against.
248
- * @param {ComparisonValidatorOptions} options - Options for the validator.
249
- * @param {string} [options.label] - The label text displayed in the error message.
250
- * @param {string} [options.message=DEFAULT_ERROR_MESSAGES.LESS_THAN] - Custom error message to be returned if validation fails.
251
- *
252
- * @returns {PropertyDecorator} A property decorator used to register the less than validation metadata.
253
- *
254
- * @function lt
255
- * @category Property Decorators
256
- */
257
- export declare function lt(propertyToCompare: string, options?: Omit<ComparisonValidatorOptions, "async" | "description">): (obj: any, prop: any) => void;
258
- /**
259
- * @summary Declares that the decorated property must be equal or less than another specified property.
260
- * @description Applies the {@link ValidationKeys.LESS_THAN_OR_EQUAL} validator to ensure the decorated value is equal or less than the value of the given property.
261
- *
262
- * @param {string} propertyToCompare - The name of the property to compare against.
263
- * @param {ComparisonValidatorOptions} options - Options for the validator.
264
- * @param {string} [options.label] - The label text displayed in the error message.
265
- * @param {string} [options.message=DEFAULT_ERROR_MESSAGES.LESS_THAN_OR_EQUAL] - Custom error message to be returned if validation fails.
266
- *
267
- * @returns {PropertyDecorator} A property decorator used to register the less than or equal validation metadata.
268
- *
269
- * @function lte
270
- * @category Property Decorators
271
- */
272
- export declare function lte(propertyToCompare: string, options?: Omit<ComparisonValidatorOptions, "async" | "description">): (obj: any, prop: any) => void;
273
- /**
274
- * @summary Declares that the decorated property must be greater than another specified property.
275
- * @description Applies the {@link ValidationKeys.GREATER_THAN} validator to ensure the decorated value is greater than the value of the given property.
276
- *
277
- * @param {string} propertyToCompare - The name of the property to compare against.
278
- * @param {ComparisonValidatorOptions} options - Options for the validator.
279
- * @param {string} [options.label] - The label text displayed in the error message.
280
- * @param {string} [options.message=DEFAULT_ERROR_MESSAGES.GREATER_THAN] - Custom error message to be returned if validation fails.
281
- *
282
- * @returns {PropertyDecorator} A property decorator used to register the greater than validation metadata.
283
- *
284
- * @function gt
285
- * @category Property Decorators
286
- */
287
- export declare function gt(propertyToCompare: string, options?: Omit<ComparisonValidatorOptions, "async" | "description">): (obj: any, prop: any) => void;
288
- /**
289
- * @summary Declares that the decorated property must be equal or greater than another specified property.
290
- * @description Applies the {@link ValidationKeys.GREATER_THAN_OR_EQUAL} validator to ensure the decorated value is equal or greater than the value of the given property.
291
- *
292
- * @param {string} propertyToCompare - The name of the property to compare against.
293
- * @param {ComparisonValidatorOptions} options - Options for the validator.
294
- * @param {string} [options.label] - The label text displayed in the error message.
295
- * @param {string} [options.message=DEFAULT_ERROR_MESSAGES.GREATER_THAN_OR_EQUAL] - Custom error message to be returned if validation fails.
296
- *
297
- * @returns {PropertyDecorator} A property decorator used to register the greater than or equal validation metadata.
298
- *
299
- * @function gte
300
- * @category Property Decorators
301
- */
302
- export declare function gte(propertyToCompare: string, options?: Omit<ComparisonValidatorOptions, "async" | "description">): (obj: any, prop: any) => void;
303
- /**
304
- * @summary Defines a list or an object of accepted values for the property
305
- * @description Validators to validate a decorated property must use key {@link ValidationKeys#ENUM}
306
- *
307
- * @param {any[] | Record<any, any>} value
308
- * @param {string} [message] the error message. Defaults to {@link DEFAULT_ERROR_MESSAGES#ENUM}
309
- *
310
- * @function option
311
- * @category Property Decorators
312
- */
313
- export declare function option(value: any[] | Record<any, any>, message?: string): (target: any, propertyKey?: any, descriptor?: TypedPropertyDescriptor<any>) => any;
@@ -1,9 +0,0 @@
1
- /**
2
- * @description Exports for the validation module.
3
- * @summary This file exports all the necessary components for the validation functionality, including validators, decorators, types, and the Validation class.
4
- * @module decorator-validation/validation
5
- */
6
- export * from "./Validators";
7
- export * from "./decorators";
8
- export * from "./types";
9
- export * from "./Validation";