kmod-cli 1.7.1 → 1.7.2
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.
|
@@ -67,7 +67,7 @@ export const REGEXS = {
|
|
|
67
67
|
*/
|
|
68
68
|
text: /^[a-zA-ZÀ-ỹ0-9\s]+$/,
|
|
69
69
|
/**
|
|
70
|
-
* /^[a-zA-
|
|
70
|
+
* /^[a-zA-ZÀ-ỹ0-9\s.,#\/-]+$/
|
|
71
71
|
* @example "123 Main St, Anytown, USA"
|
|
72
72
|
*/
|
|
73
73
|
address: /^[a-zA-ZÀ-ỹ0-9\s.,#\/-]+$/,
|
|
@@ -92,9 +92,9 @@ interface ValidationRule {
|
|
|
92
92
|
errorMessage?: string;
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
export type ValidationRules<T> = {
|
|
95
|
+
export type ValidationRules<T> = Partial<{
|
|
96
96
|
[K in keyof T]: ValidationRule;
|
|
97
|
-
}
|
|
97
|
+
}>;
|
|
98
98
|
|
|
99
99
|
type ValidationErrors<T> = {
|
|
100
100
|
[K in keyof T]?: string;
|
|
@@ -176,38 +176,11 @@ export const useFormValidator = <T extends Record<string, any>>(
|
|
|
176
176
|
};
|
|
177
177
|
|
|
178
178
|
return {
|
|
179
|
-
/**
|
|
180
|
-
* Form values
|
|
181
|
-
* - ex: values.email
|
|
182
|
-
*/
|
|
183
179
|
values,
|
|
184
|
-
/**
|
|
185
|
-
* Form errors
|
|
186
|
-
* - ex: errors.email
|
|
187
|
-
*/
|
|
188
180
|
errors,
|
|
189
|
-
/**
|
|
190
|
-
* Update the form values
|
|
191
|
-
* - ex: handleChange('email', 'a@example.com')
|
|
192
|
-
*/
|
|
193
181
|
handleChange,
|
|
194
|
-
/**
|
|
195
|
-
* Validate all form fields
|
|
196
|
-
* - ex: validateAllFields()
|
|
197
|
-
* @returns boolean
|
|
198
|
-
*/
|
|
199
182
|
validateAllFields,
|
|
200
|
-
/**
|
|
201
|
-
* Update entire the form values
|
|
202
|
-
* @param newValues
|
|
203
|
-
* - ex: setValues({ email: 'a@example.com', password: '123456' })
|
|
204
|
-
*/
|
|
205
183
|
setValues,
|
|
206
|
-
/**
|
|
207
|
-
* Validate array of fields
|
|
208
|
-
* - ex: validateFields(['email', 'password'])
|
|
209
|
-
* @returns boolean
|
|
210
|
-
*/
|
|
211
184
|
validateFields
|
|
212
185
|
};
|
|
213
186
|
};
|
|
@@ -231,4 +204,5 @@ export const useFormValidator = <T extends Record<string, any>>(
|
|
|
231
204
|
// if (validateAllFields()) {
|
|
232
205
|
// // proceed with form submission
|
|
233
206
|
// }
|
|
234
|
-
// };
|
|
207
|
+
// };
|
|
208
|
+
|