kanun 0.1.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.
- package/LICENSE +21 -0
- package/README.md +171 -0
- package/dist/index.cjs +3071 -0
- package/dist/index.d.cts +1435 -0
- package/dist/index.d.mts +1435 -0
- package/dist/index.mjs +3023 -0
- package/package.json +66 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,1435 @@
|
|
|
1
|
+
//#region src/Rules/baseRule.d.ts
|
|
2
|
+
declare class BaseRule {}
|
|
3
|
+
//#endregion
|
|
4
|
+
//#region src/Contracts/IGeneric.d.ts
|
|
5
|
+
interface GenericObject {
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
}
|
|
8
|
+
interface GenericCallable {
|
|
9
|
+
(...args: any[]): any;
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/Rules/IRuleContract.d.ts
|
|
13
|
+
declare abstract class IRuleContract {
|
|
14
|
+
/**
|
|
15
|
+
* The validation error message.
|
|
16
|
+
*/
|
|
17
|
+
message: string | object;
|
|
18
|
+
/**
|
|
19
|
+
* All of the data under validation.
|
|
20
|
+
*/
|
|
21
|
+
data: object;
|
|
22
|
+
/**
|
|
23
|
+
* The lang used to return error messages
|
|
24
|
+
*/
|
|
25
|
+
lang: string;
|
|
26
|
+
/**
|
|
27
|
+
* Determine if the validation rule passes.
|
|
28
|
+
*/
|
|
29
|
+
passes(_value: any, _attribute: string): boolean | Promise<boolean>;
|
|
30
|
+
/**
|
|
31
|
+
* Get the validation error message.
|
|
32
|
+
*/
|
|
33
|
+
getMessage(): string | object;
|
|
34
|
+
/**
|
|
35
|
+
* Set the data under validation.
|
|
36
|
+
*/
|
|
37
|
+
setData(data: object): this;
|
|
38
|
+
/**
|
|
39
|
+
* Set the tranlation language
|
|
40
|
+
*/
|
|
41
|
+
setLang(lang: string): this;
|
|
42
|
+
/**
|
|
43
|
+
* Get the translated error message based on the specified path
|
|
44
|
+
*/
|
|
45
|
+
trans(path: string, params?: GenericObject): string;
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region src/payloads/replaceAttributePayload.d.ts
|
|
49
|
+
declare class replaceAttributePayload {
|
|
50
|
+
/**
|
|
51
|
+
* Stores the data object
|
|
52
|
+
*/
|
|
53
|
+
data: GenericObject;
|
|
54
|
+
/**
|
|
55
|
+
* The message in which attributes will be replaced
|
|
56
|
+
*/
|
|
57
|
+
message: string;
|
|
58
|
+
/**
|
|
59
|
+
* Parameters that will be used to replace the attributes
|
|
60
|
+
*/
|
|
61
|
+
parameters: string[];
|
|
62
|
+
/**
|
|
63
|
+
* Flag that identifies wether the numeric rule exists or not
|
|
64
|
+
*/
|
|
65
|
+
hasNumericRule: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* The function that will be used to format attributes
|
|
68
|
+
*/
|
|
69
|
+
getDisplayableAttribute: (key: string) => string;
|
|
70
|
+
constructor(data: GenericObject, message: string, parameters: string[], hasNumericRule: boolean, getDisplayableAttribute: (key: string) => string);
|
|
71
|
+
}
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region src/Contracts/BaseContract.d.ts
|
|
74
|
+
type InitialRule = string | ValidationCallback | IRuleContract | BaseRule;
|
|
75
|
+
type TRule = string | IRuleContract;
|
|
76
|
+
interface InitialRules extends GenericObject {
|
|
77
|
+
[key: string]: InitialRule | InitialRule[];
|
|
78
|
+
}
|
|
79
|
+
interface Rules extends GenericObject {
|
|
80
|
+
[key: string]: TRule[];
|
|
81
|
+
}
|
|
82
|
+
interface ImplicitAttributes {
|
|
83
|
+
[key: string]: string[];
|
|
84
|
+
}
|
|
85
|
+
type CustomMessages = GenericObject & {};
|
|
86
|
+
type CustomAttributes = GenericObject & {};
|
|
87
|
+
interface ErrorMessage {
|
|
88
|
+
error_type?: string;
|
|
89
|
+
message: string;
|
|
90
|
+
}
|
|
91
|
+
interface Errors {
|
|
92
|
+
[key: string]: ErrorMessage[];
|
|
93
|
+
}
|
|
94
|
+
interface Messages {
|
|
95
|
+
[key: string]: string[];
|
|
96
|
+
}
|
|
97
|
+
interface CustomErrors {
|
|
98
|
+
[key: string]: string | string[];
|
|
99
|
+
}
|
|
100
|
+
interface ValidationRuleParserInterface {
|
|
101
|
+
/**
|
|
102
|
+
* Convert rules to array
|
|
103
|
+
*
|
|
104
|
+
* @param rules
|
|
105
|
+
* @param data
|
|
106
|
+
* @returns
|
|
107
|
+
*/
|
|
108
|
+
explodeRules: (rules: Rules | InitialRule[], data?: GenericObject) => {
|
|
109
|
+
rules: Rules;
|
|
110
|
+
implicitAttributes: ImplicitAttributes;
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* Define a set of rules that apply to each element in an array attribute.
|
|
114
|
+
*
|
|
115
|
+
* @param results
|
|
116
|
+
* @param attribute
|
|
117
|
+
* @param data
|
|
118
|
+
* @param implicitAttributes
|
|
119
|
+
* @returns
|
|
120
|
+
*/
|
|
121
|
+
explodeWildCardRules: (results: GenericObject, attribute: string, data: GenericObject, implicitAttributes: ImplicitAttributes) => GenericObject;
|
|
122
|
+
/**
|
|
123
|
+
* Explode rules that are in string format into array format.
|
|
124
|
+
*
|
|
125
|
+
* @param rule
|
|
126
|
+
* @returns
|
|
127
|
+
*/
|
|
128
|
+
explodeExplicitRules: (rule: string | InitialRule[]) => TRule[];
|
|
129
|
+
/**
|
|
130
|
+
* Prepare the given rule for validation.
|
|
131
|
+
*
|
|
132
|
+
* @param rule
|
|
133
|
+
* @returns
|
|
134
|
+
*/
|
|
135
|
+
prepareRule: (rule: InitialRule) => TRule;
|
|
136
|
+
/**
|
|
137
|
+
* Merge the given rules with any existing rules for the attribute.
|
|
138
|
+
*
|
|
139
|
+
* @param results
|
|
140
|
+
* @param attribute
|
|
141
|
+
* @param rules
|
|
142
|
+
* @returns
|
|
143
|
+
*/
|
|
144
|
+
mergeRulesForAttribute: (results: GenericObject, attribute: string, rules: string | InitialRule[]) => GenericObject;
|
|
145
|
+
/**
|
|
146
|
+
* Parse a rule into its name and parameters.
|
|
147
|
+
*
|
|
148
|
+
* @param rule
|
|
149
|
+
* @returns
|
|
150
|
+
*/
|
|
151
|
+
parse: (rule: TRule) => [TRule, string[]];
|
|
152
|
+
/**
|
|
153
|
+
* Parse a string rule into its name and parameters.
|
|
154
|
+
*
|
|
155
|
+
* @param rule
|
|
156
|
+
* @returns
|
|
157
|
+
*/
|
|
158
|
+
parseStringRule: (rule: string) => [string, string[]];
|
|
159
|
+
/**
|
|
160
|
+
* Get a specific rule from the ruleset for an attribute.
|
|
161
|
+
*
|
|
162
|
+
* @param attribute
|
|
163
|
+
* @param searchRules
|
|
164
|
+
* @param availableRules
|
|
165
|
+
* @returns
|
|
166
|
+
*/
|
|
167
|
+
getRule: (attribute: string, searchRules: string | string[], availableRules: Rules) => Partial<[string, string[]]>;
|
|
168
|
+
/**
|
|
169
|
+
* Determine if a rule exists in the ruleset for an attribute.
|
|
170
|
+
*
|
|
171
|
+
* @param attribute
|
|
172
|
+
* @param searchRules
|
|
173
|
+
* @param availableRules
|
|
174
|
+
* @returns
|
|
175
|
+
*/
|
|
176
|
+
hasRule: (attribute: string, searchRules: string | string[], availableRules: Rules) => boolean;
|
|
177
|
+
}
|
|
178
|
+
interface ValidationDataInterface {
|
|
179
|
+
initializeAndGatherData: (attribute: string, masterData: object) => object;
|
|
180
|
+
initializeAttributeOnData: (attribute: string, masterData: object) => object;
|
|
181
|
+
extractValuesFromWildCards: (masterData: object, data: object, attribute: string) => object;
|
|
182
|
+
getLeadingExplicitAttributePath: (attribute: string) => string;
|
|
183
|
+
extractDataFromPath: (path: string, masterData: object) => object;
|
|
184
|
+
}
|
|
185
|
+
interface ReplaceAttributeInterface {
|
|
186
|
+
replaceAcceptedIf: (payload: replaceAttributePayload) => string;
|
|
187
|
+
replaceBefore: (payload: replaceAttributePayload) => string;
|
|
188
|
+
replaceBeforeOrEqual: (payload: replaceAttributePayload) => string;
|
|
189
|
+
replaceAfter: (payload: replaceAttributePayload) => string;
|
|
190
|
+
replaceAfterOrEqual: (payload: replaceAttributePayload) => string;
|
|
191
|
+
replaceBetween: (payload: replaceAttributePayload) => string;
|
|
192
|
+
replaceDateEquals: (payload: replaceAttributePayload) => string;
|
|
193
|
+
replaceDeclinedIf: (payload: replaceAttributePayload) => string;
|
|
194
|
+
replaceDigits: (payload: replaceAttributePayload) => string;
|
|
195
|
+
replaceDigitsBetween: (payload: replaceAttributePayload) => string;
|
|
196
|
+
replaceDifferent: (payload: replaceAttributePayload) => string;
|
|
197
|
+
replaceEndsWith: (payload: replaceAttributePayload) => string;
|
|
198
|
+
replaceIn: (payload: replaceAttributePayload) => string;
|
|
199
|
+
replaceMin: (payload: replaceAttributePayload) => string;
|
|
200
|
+
replaceMax: (payload: replaceAttributePayload) => string;
|
|
201
|
+
replaceRequiredWith: (payload: replaceAttributePayload) => string;
|
|
202
|
+
replaceRequiredWithAll: (payload: replaceAttributePayload) => string;
|
|
203
|
+
replaceRequiredWithout: (payload: replaceAttributePayload) => string;
|
|
204
|
+
replaceRequiredWithoutAll: (payload: replaceAttributePayload) => string;
|
|
205
|
+
replaceGt: (payload: replaceAttributePayload) => string;
|
|
206
|
+
replaceLt: (payload: replaceAttributePayload) => string;
|
|
207
|
+
replaceGte: (payload: replaceAttributePayload) => string;
|
|
208
|
+
replaceLte: (payload: replaceAttributePayload) => string;
|
|
209
|
+
replaceRequiredIf: (payload: replaceAttributePayload) => string;
|
|
210
|
+
replaceStartsWith: (payload: replaceAttributePayload) => string;
|
|
211
|
+
replaceRequiredUnless: (payload: replaceAttributePayload) => string;
|
|
212
|
+
replaceSame: (payload: replaceAttributePayload) => string;
|
|
213
|
+
replaceSize: (payload: replaceAttributePayload) => string;
|
|
214
|
+
}
|
|
215
|
+
type ValidationCallback = (value: any, fail: (message: string) => void, attribute: string) => void;
|
|
216
|
+
//#endregion
|
|
217
|
+
//#region src/validators/errorBag.d.ts
|
|
218
|
+
declare class ErrorBag {
|
|
219
|
+
/**
|
|
220
|
+
* All of the registered messages.
|
|
221
|
+
*/
|
|
222
|
+
errors: Errors;
|
|
223
|
+
/**
|
|
224
|
+
* All Messages
|
|
225
|
+
*/
|
|
226
|
+
messages: Messages;
|
|
227
|
+
/**
|
|
228
|
+
* Stores the first error message
|
|
229
|
+
*/
|
|
230
|
+
firstMessage: string;
|
|
231
|
+
/**
|
|
232
|
+
* Specify whether error types should be returned or no
|
|
233
|
+
*/
|
|
234
|
+
withErrorTypes: boolean;
|
|
235
|
+
constructor(errors?: Errors, messages?: Messages, firstMessage?: string, withErrorTypes?: boolean);
|
|
236
|
+
/**
|
|
237
|
+
* Set withErrorTypes attribute to true
|
|
238
|
+
*/
|
|
239
|
+
addErrorTypes(): ErrorBag;
|
|
240
|
+
/**
|
|
241
|
+
* Add new recodrs to the errors and messages objects
|
|
242
|
+
*/
|
|
243
|
+
add(key: string, error: ErrorMessage): void;
|
|
244
|
+
/**
|
|
245
|
+
* Get the first error related to a specific key
|
|
246
|
+
*/
|
|
247
|
+
first(key?: string | null): string;
|
|
248
|
+
/**
|
|
249
|
+
* Get the error messages keys
|
|
250
|
+
*/
|
|
251
|
+
keys(): string[];
|
|
252
|
+
/**
|
|
253
|
+
* Get all the messages related to a specific key
|
|
254
|
+
*/
|
|
255
|
+
get(key: string, withErrorTypes?: boolean): ErrorMessage[] | string[];
|
|
256
|
+
/**
|
|
257
|
+
* Check if key exists in messages
|
|
258
|
+
*/
|
|
259
|
+
has(key: string): boolean;
|
|
260
|
+
/**
|
|
261
|
+
* Get all error messages
|
|
262
|
+
*/
|
|
263
|
+
all(allMessages?: boolean, withErrorTypes?: boolean): GenericObject;
|
|
264
|
+
/**
|
|
265
|
+
* Remove error messages
|
|
266
|
+
*/
|
|
267
|
+
clear(keys: string[]): ErrorBag;
|
|
268
|
+
/**
|
|
269
|
+
* Clone ErrorBag Instance
|
|
270
|
+
*/
|
|
271
|
+
clone(): ErrorBag;
|
|
272
|
+
}
|
|
273
|
+
//#endregion
|
|
274
|
+
//#region src/BaseValidator.d.ts
|
|
275
|
+
declare class BaseValidator {
|
|
276
|
+
/**
|
|
277
|
+
* The lang used to return error messages
|
|
278
|
+
*/
|
|
279
|
+
private lang;
|
|
280
|
+
/**
|
|
281
|
+
* The data object that will be validated
|
|
282
|
+
*/
|
|
283
|
+
private data;
|
|
284
|
+
/**
|
|
285
|
+
* The rules that will be used to check the validity of the data
|
|
286
|
+
*/
|
|
287
|
+
private rules;
|
|
288
|
+
/**
|
|
289
|
+
* This is an unchanged version of the inital rules before being changed for wildcard validations
|
|
290
|
+
*/
|
|
291
|
+
private initalRules;
|
|
292
|
+
/**
|
|
293
|
+
* The array of wildcard attributes with their asterisks expanded.
|
|
294
|
+
*/
|
|
295
|
+
private implicitAttributes;
|
|
296
|
+
/**
|
|
297
|
+
* Hold the error messages
|
|
298
|
+
*/
|
|
299
|
+
private messages;
|
|
300
|
+
/**
|
|
301
|
+
* Stores an instance of the validateAttributes class
|
|
302
|
+
*/
|
|
303
|
+
private validateAttributes;
|
|
304
|
+
/**
|
|
305
|
+
* Flag that defines wether or not validation should stop on first failure
|
|
306
|
+
*/
|
|
307
|
+
private stopOnFirstFailureFlag;
|
|
308
|
+
/**
|
|
309
|
+
* Custom messages returned based on the error
|
|
310
|
+
*/
|
|
311
|
+
customMessages: CustomMessages;
|
|
312
|
+
/**
|
|
313
|
+
* Object of custom attribute name;
|
|
314
|
+
*/
|
|
315
|
+
customAttributes: CustomAttributes;
|
|
316
|
+
constructor(data: object, rules: InitialRules, customMessages?: CustomMessages, customAttributes?: CustomAttributes);
|
|
317
|
+
setData(data: object): this;
|
|
318
|
+
setRules(rules: InitialRules): this;
|
|
319
|
+
setLang(lang: string): this;
|
|
320
|
+
getLang(): string;
|
|
321
|
+
setCustomMessages(customMessages?: CustomMessages): this;
|
|
322
|
+
setCustomAttributes(customAttributes?: CustomAttributes): this;
|
|
323
|
+
stopOnFirstFailure(stopOnFirstFailure?: boolean): this;
|
|
324
|
+
errors(): ErrorBag;
|
|
325
|
+
clearErrors(keys?: string[]): ErrorBag;
|
|
326
|
+
/**
|
|
327
|
+
* Create a new ErrorBag instance and set the custom errors, thus removing previous error messages
|
|
328
|
+
*/
|
|
329
|
+
setErrors(errors: CustomErrors): ErrorBag;
|
|
330
|
+
/**
|
|
331
|
+
* Append the error messages to the existing ErrorBag instance, thus preserving the old error messages if any
|
|
332
|
+
*/
|
|
333
|
+
appendErrors(errors: CustomErrors): ErrorBag;
|
|
334
|
+
/**
|
|
335
|
+
* Run the validator's rules against its data.
|
|
336
|
+
*/
|
|
337
|
+
validate(key?: string, value?: any): boolean;
|
|
338
|
+
/**
|
|
339
|
+
* Run the validator's rules against its data asynchronously.
|
|
340
|
+
*/
|
|
341
|
+
validateAsync(key?: string, value?: any): Promise<boolean>;
|
|
342
|
+
/**
|
|
343
|
+
* Get the displayable name of the attribute.
|
|
344
|
+
*/
|
|
345
|
+
getDisplayableAttribute(attribute: string): string;
|
|
346
|
+
private addCustomErrors;
|
|
347
|
+
/**
|
|
348
|
+
* Replace all error message place-holders with actual values.
|
|
349
|
+
*/
|
|
350
|
+
private makeReplacements;
|
|
351
|
+
/**
|
|
352
|
+
* Loop through all rules and run validation against each one of them
|
|
353
|
+
*/
|
|
354
|
+
private runAllValidations;
|
|
355
|
+
/**
|
|
356
|
+
* Loop through all rules and run validation against each one of them asynchronously.
|
|
357
|
+
*/
|
|
358
|
+
private runAllValidationsAsync;
|
|
359
|
+
/**
|
|
360
|
+
* Run validation for one specific attribute
|
|
361
|
+
*/
|
|
362
|
+
private runSingleValidation;
|
|
363
|
+
/**
|
|
364
|
+
* Run validation for one specific attribute asynchronously.
|
|
365
|
+
*/
|
|
366
|
+
private runSingleValidationAsync;
|
|
367
|
+
/**
|
|
368
|
+
* Run validation rules for the specified property and stop validation if needed
|
|
369
|
+
*/
|
|
370
|
+
private runValidation;
|
|
371
|
+
/**
|
|
372
|
+
* Run validation rules for the specified property asynchronously and stop validation if needed
|
|
373
|
+
*/
|
|
374
|
+
private runValidationAsync;
|
|
375
|
+
/**
|
|
376
|
+
* Check if we should stop further validations on a given attribute.
|
|
377
|
+
*/
|
|
378
|
+
private shouldStopValidating;
|
|
379
|
+
/**
|
|
380
|
+
* Parse the given rules add assign them to the current rules
|
|
381
|
+
*/
|
|
382
|
+
private addRules;
|
|
383
|
+
/**
|
|
384
|
+
* validate a given attribute against a rule.
|
|
385
|
+
*/
|
|
386
|
+
private validateAttribute;
|
|
387
|
+
/**
|
|
388
|
+
* Validate an attribute using a custom rule object
|
|
389
|
+
*/
|
|
390
|
+
private validateUsingCustomRule;
|
|
391
|
+
/**
|
|
392
|
+
* Set the error message linked to a custom validation rule
|
|
393
|
+
*/
|
|
394
|
+
private setCustomRuleErrorMessages;
|
|
395
|
+
/**
|
|
396
|
+
* Add a new error message to the messages object
|
|
397
|
+
*/
|
|
398
|
+
private addFailure;
|
|
399
|
+
/**
|
|
400
|
+
* Replace each field parameter which has asterisks with the given keys.
|
|
401
|
+
*
|
|
402
|
+
* Example: parameters = [name.*.first] and keys = [1], then the result will be name.1.first
|
|
403
|
+
*/
|
|
404
|
+
private replaceAsterisksInParameters;
|
|
405
|
+
/**
|
|
406
|
+
* Determine if the attribute is validatable.
|
|
407
|
+
*/
|
|
408
|
+
private isValidatable;
|
|
409
|
+
/**
|
|
410
|
+
* Determine if the field is present, or the rule implies required.
|
|
411
|
+
*/
|
|
412
|
+
private presentOrRuleIsImplicit;
|
|
413
|
+
/**
|
|
414
|
+
* Determine if the attribute passes any optional check.
|
|
415
|
+
*/
|
|
416
|
+
private passesOptionalCheck;
|
|
417
|
+
/**
|
|
418
|
+
* Determine if the attribute fails the nullable check.
|
|
419
|
+
*/
|
|
420
|
+
private isNotNullIfMarkedAsNullable;
|
|
421
|
+
/**
|
|
422
|
+
* Get the primary attribute name
|
|
423
|
+
*
|
|
424
|
+
* Example: if "name.0" is given, "name.*" will be returned
|
|
425
|
+
*/
|
|
426
|
+
private getPrimaryAttribute;
|
|
427
|
+
/**
|
|
428
|
+
* Get the explicit keys from an attribute flattened with dot notation.
|
|
429
|
+
*
|
|
430
|
+
* Example: 'foo.1.bar.spark.baz' -> [1, 'spark'] for 'foo.*.bar.*.baz'
|
|
431
|
+
*/
|
|
432
|
+
private getExplicitKeys;
|
|
433
|
+
}
|
|
434
|
+
//#endregion
|
|
435
|
+
//#region src/Contracts/IDatabaseDriver.d.ts
|
|
436
|
+
interface ValidationDatabaseExistsInput {
|
|
437
|
+
table: string;
|
|
438
|
+
column: string;
|
|
439
|
+
value: any;
|
|
440
|
+
ignore?: any;
|
|
441
|
+
connection?: string;
|
|
442
|
+
attribute?: string;
|
|
443
|
+
data?: Record<string, any>;
|
|
444
|
+
}
|
|
445
|
+
declare abstract class IDatabaseDriver {
|
|
446
|
+
abstract exists(input: ValidationDatabaseExistsInput): boolean | Promise<boolean>;
|
|
447
|
+
}
|
|
448
|
+
//#endregion
|
|
449
|
+
//#region src/Contracts/IMessageBag.d.ts
|
|
450
|
+
declare class ValidationMessageProvider {
|
|
451
|
+
getMessageBag(): IMessageBag;
|
|
452
|
+
}
|
|
453
|
+
declare class IMessageBag implements ValidationMessageProvider {
|
|
454
|
+
/**
|
|
455
|
+
* Create a new message bag instance.
|
|
456
|
+
*/
|
|
457
|
+
constructor(messages: Record<string, string[] | string>);
|
|
458
|
+
getMessageBag(): IMessageBag;
|
|
459
|
+
/**
|
|
460
|
+
* Get all message keys.
|
|
461
|
+
*/
|
|
462
|
+
keys(): string[];
|
|
463
|
+
/**
|
|
464
|
+
* Add a message.
|
|
465
|
+
*/
|
|
466
|
+
add(key: string, message: string): this;
|
|
467
|
+
/**
|
|
468
|
+
* Add a message conditionally.
|
|
469
|
+
*/
|
|
470
|
+
addIf(condition: boolean, key: string, message: string): this;
|
|
471
|
+
/**
|
|
472
|
+
* Merge another message source into this one.
|
|
473
|
+
*/
|
|
474
|
+
merge(messages: Record<string, string[]> | ValidationMessageProvider): this;
|
|
475
|
+
/**
|
|
476
|
+
* Determine if messages exist for all given keys.
|
|
477
|
+
*/
|
|
478
|
+
has(key?: string | string[] | null): boolean;
|
|
479
|
+
/**
|
|
480
|
+
* Determine if messages exist for any given key.
|
|
481
|
+
*/
|
|
482
|
+
hasAny(keys: string | string[]): boolean;
|
|
483
|
+
/**
|
|
484
|
+
* Determine if messages don't exist for given keys.
|
|
485
|
+
*/
|
|
486
|
+
missing(key: string | string[]): boolean;
|
|
487
|
+
/**
|
|
488
|
+
* Get the first message for a given key.
|
|
489
|
+
*/
|
|
490
|
+
first(key?: string | null, format?: string | null): string;
|
|
491
|
+
/**
|
|
492
|
+
* Get all messages for a given key.
|
|
493
|
+
*/
|
|
494
|
+
get(key: string, format?: string | null): string[] | Record<string, string[]>;
|
|
495
|
+
/**
|
|
496
|
+
* Get all messages.
|
|
497
|
+
*/
|
|
498
|
+
all(format?: string): string[];
|
|
499
|
+
/**
|
|
500
|
+
* Get unique messages.
|
|
501
|
+
*/
|
|
502
|
+
unique(format?: string | null): string[];
|
|
503
|
+
/**
|
|
504
|
+
* Remove messages for a key.
|
|
505
|
+
*/
|
|
506
|
+
forget(key: string): this;
|
|
507
|
+
/**
|
|
508
|
+
* Get raw messages.
|
|
509
|
+
*/
|
|
510
|
+
messagesRaw(): Record<string, string[]>;
|
|
511
|
+
/**
|
|
512
|
+
* Alias for messagesRaw().
|
|
513
|
+
*/
|
|
514
|
+
getMessages(): Record<string, string[]>;
|
|
515
|
+
/**
|
|
516
|
+
* Return message bag instance.
|
|
517
|
+
*/
|
|
518
|
+
getMessageBag(): IMessageBag;
|
|
519
|
+
/**
|
|
520
|
+
* Get format string.
|
|
521
|
+
*/
|
|
522
|
+
getFormat(): string;
|
|
523
|
+
/**
|
|
524
|
+
* Set default message format.
|
|
525
|
+
*/
|
|
526
|
+
setFormat(format: string): this;
|
|
527
|
+
/**
|
|
528
|
+
* Empty checks.
|
|
529
|
+
*/
|
|
530
|
+
isEmpty(): boolean;
|
|
531
|
+
isNotEmpty(): boolean;
|
|
532
|
+
any(): boolean;
|
|
533
|
+
/**
|
|
534
|
+
* Count total messages.
|
|
535
|
+
*/
|
|
536
|
+
count(): number;
|
|
537
|
+
/**
|
|
538
|
+
* Array & JSON conversions.
|
|
539
|
+
*/
|
|
540
|
+
toArray(): Record<string, string[]>;
|
|
541
|
+
jsonSerialize(): any;
|
|
542
|
+
toJson(options: number): string;
|
|
543
|
+
toPrettyJson(): string;
|
|
544
|
+
/**
|
|
545
|
+
* String representation.
|
|
546
|
+
*/
|
|
547
|
+
toString(): string;
|
|
548
|
+
}
|
|
549
|
+
//#endregion
|
|
550
|
+
//#region src/Contracts/RuleBuilder.d.ts
|
|
551
|
+
interface ValidationRuleCallable {
|
|
552
|
+
name: string;
|
|
553
|
+
validator: (value: any, parameters?: string[], attribute?: string) => boolean | Promise<boolean>;
|
|
554
|
+
message?: string;
|
|
555
|
+
}
|
|
556
|
+
type CustomValidationRules = IValidationRule | ValidationRuleCallable;
|
|
557
|
+
declare class BaseValidationRuleClass {}
|
|
558
|
+
//#endregion
|
|
559
|
+
//#region src/Contracts/IValidationRule.d.ts
|
|
560
|
+
declare abstract class IValidationRule {
|
|
561
|
+
rules: ValidationRuleCallable[];
|
|
562
|
+
/**
|
|
563
|
+
* Run the validation rule.
|
|
564
|
+
*/
|
|
565
|
+
abstract validate(attribute: string, value: any, fail: (msg: string) => any): void;
|
|
566
|
+
/**
|
|
567
|
+
* Set the current validator.
|
|
568
|
+
*/
|
|
569
|
+
/**
|
|
570
|
+
* Set the data under validation.
|
|
571
|
+
*/
|
|
572
|
+
setData(_data: Record<string, any>): this;
|
|
573
|
+
passes(value: any, attribute: string): boolean | Promise<boolean>;
|
|
574
|
+
}
|
|
575
|
+
//#endregion
|
|
576
|
+
//#region src/Rules/in.d.ts
|
|
577
|
+
declare class In extends BaseRule {
|
|
578
|
+
/**
|
|
579
|
+
* The name of the rule.
|
|
580
|
+
*/
|
|
581
|
+
rule: string;
|
|
582
|
+
/**
|
|
583
|
+
* The accepted values.
|
|
584
|
+
*/
|
|
585
|
+
values: (string | number)[];
|
|
586
|
+
/**
|
|
587
|
+
* Create a new In rule instance.
|
|
588
|
+
*/
|
|
589
|
+
constructor(values: (string | number)[]);
|
|
590
|
+
/**
|
|
591
|
+
* Convert the rule to a validation string.
|
|
592
|
+
*/
|
|
593
|
+
toString(): string;
|
|
594
|
+
}
|
|
595
|
+
//#endregion
|
|
596
|
+
//#region src/Rules/notIn.d.ts
|
|
597
|
+
declare class NotIn extends BaseRule {
|
|
598
|
+
/**
|
|
599
|
+
* The name of the rule.
|
|
600
|
+
*/
|
|
601
|
+
rule: string;
|
|
602
|
+
/**
|
|
603
|
+
* The accepted values.
|
|
604
|
+
*/
|
|
605
|
+
values: (string | number)[];
|
|
606
|
+
/**
|
|
607
|
+
* Create a new NotIn rule instance.
|
|
608
|
+
*/
|
|
609
|
+
constructor(values: (string | number)[]);
|
|
610
|
+
/**
|
|
611
|
+
* Convert the rule to a validation string.
|
|
612
|
+
*/
|
|
613
|
+
toString(): string;
|
|
614
|
+
}
|
|
615
|
+
//#endregion
|
|
616
|
+
//#region src/Rules/regex.d.ts
|
|
617
|
+
declare class Regex extends IRuleContract {
|
|
618
|
+
/**
|
|
619
|
+
* The Regular expression to validate
|
|
620
|
+
*/
|
|
621
|
+
regex: RegExp;
|
|
622
|
+
/**
|
|
623
|
+
* Flag that decides whether the value should match the regular expression or not
|
|
624
|
+
*/
|
|
625
|
+
shouldMatch: boolean;
|
|
626
|
+
constructor(regex: RegExp, shouldMatch?: boolean);
|
|
627
|
+
passes(value: any): boolean;
|
|
628
|
+
getMessage(): string;
|
|
629
|
+
}
|
|
630
|
+
//#endregion
|
|
631
|
+
//#region src/Rules/requiredIf.d.ts
|
|
632
|
+
declare class RequiredIf extends BaseRule {
|
|
633
|
+
/**
|
|
634
|
+
* The condition that validates the attribute
|
|
635
|
+
*/
|
|
636
|
+
condition: boolean | CallableFunction;
|
|
637
|
+
/**
|
|
638
|
+
* Create a new required validation rule based on a condition.
|
|
639
|
+
*/
|
|
640
|
+
constructor(condition: boolean | CallableFunction);
|
|
641
|
+
/**
|
|
642
|
+
* Convert the rule to a validation string.
|
|
643
|
+
*/
|
|
644
|
+
toString(): string;
|
|
645
|
+
}
|
|
646
|
+
//#endregion
|
|
647
|
+
//#region src/Contracts/ValidationRuleName.d.ts
|
|
648
|
+
type ParamableValidationRuleName = 'accepted_if' | 'after' | 'after_or_equal' | 'before' | 'before_or_equal' | 'between' | 'date_equals' | 'datetime' | 'declined_if' | 'digits_between' | 'different' | 'exists' | 'ends_with' | 'gt' | 'gte' | 'in' | 'includes' | 'lt' | 'lte' | 'max' | 'min' | 'not_in' | 'not_includes' | 'required_if' | 'required_unless' | 'required_with' | 'required_with_all' | 'required_without' | 'required_without_all' | 'same' | 'size' | 'starts_with' | 'unique';
|
|
649
|
+
type PlainRuleName = 'accepted' | 'alpha' | 'alpha_dash' | 'alpha_num' | 'array' | 'array_unique' | 'bail' | 'boolean' | 'confirmed' | 'date' | 'declined' | 'digits' | 'email' | 'integer' | 'json' | 'not_regex' | 'nullable' | 'numeric' | 'object' | 'present' | 'regex' | 'required' | 'sometimes' | 'string' | 'url' | 'hex' | 'uuid';
|
|
650
|
+
type ValidationRuleName = ParamableValidationRuleName | PlainRuleName;
|
|
651
|
+
type MethodRules = Regex | In | NotIn | RequiredIf;
|
|
652
|
+
/**
|
|
653
|
+
* Single rule value (supports autocomplete + arbitrary strings + RuleContract instances)
|
|
654
|
+
*/
|
|
655
|
+
type RuleName = ValidationRuleName | `${ParamableValidationRuleName}:${string}` | IRuleContract | MethodRules;
|
|
656
|
+
type ValidationRuleSet = RuleName | RuleName[] | `${ValidationRuleName}${string & `|${string}`}`;
|
|
657
|
+
//#endregion
|
|
658
|
+
//#region src/Contracts/ValidatorContracts.d.ts
|
|
659
|
+
/**
|
|
660
|
+
* Parse rule names from rule string or string[] definitions
|
|
661
|
+
*/
|
|
662
|
+
type ExtractRules<R> = R extends string ? R extends `${infer Head}|${infer Tail}` ? Head extends `${infer Rule}:${string}` ? Rule | ExtractRules<Tail> : Head | ExtractRules<Tail> : R extends `${infer Rule}:${string}` ? Rule : R : R extends string[] ? ExtractRules<R[number]> : never;
|
|
663
|
+
/**
|
|
664
|
+
* Flatten data structure into dot-notation keys
|
|
665
|
+
* including wildcards (*) for arrays.
|
|
666
|
+
*/
|
|
667
|
+
type DotPaths<T, Prefix extends string = ''> = { [K in keyof T & string]: T[K] extends (infer A)[] ? `${Prefix}${K}` | `${Prefix}${K}.*` | (A extends Record<string, any> ? `${Prefix}${K}.*.${DotPaths<A>}` : never) : T[K] extends Record<string, any> ? `${Prefix}${K}` | `${Prefix}${K}.${DotPaths<T[K]>}` : `${Prefix}${K}` }[keyof T & string];
|
|
668
|
+
/**
|
|
669
|
+
* Builds message keys only for rules used on that field
|
|
670
|
+
*/
|
|
671
|
+
type FieldMessages<Field extends string, R> = `${Field}` | `${Field}.${ExtractRules<R> & ValidationRuleName}`;
|
|
672
|
+
/**
|
|
673
|
+
* Build all valid message keys for a given rules object
|
|
674
|
+
*/
|
|
675
|
+
type MessagesForRules<Rules extends Record<string, any>> = { [K in keyof Rules & string]: FieldMessages<K, Rules[K]> }[keyof Rules & string];
|
|
676
|
+
/**
|
|
677
|
+
* Make rules align with keys in the data object
|
|
678
|
+
*/
|
|
679
|
+
type RulesForData<D extends Record<string, any>> = Partial<Record<DotPaths<D>, ValidationRuleSet>>;
|
|
680
|
+
//#endregion
|
|
681
|
+
//#region src/Contracts/IValidator.d.ts
|
|
682
|
+
declare class IValidator<D extends Record<string, any> = any, R extends RulesForData<D> = RulesForData<D>> {
|
|
683
|
+
constructor(data: D, rules: R, messages: Partial<Record<MessagesForRules<R>, string>>);
|
|
684
|
+
/**
|
|
685
|
+
* Validate the data and return the instance
|
|
686
|
+
*/
|
|
687
|
+
static make<D extends Record<string, any>, R extends RulesForData<D>>(data: D, rules: R, messages: Partial<Record<MessagesForRules<R>, string>>): IValidator<D, R>;
|
|
688
|
+
static useDatabase(driver: IDatabaseDriver): typeof IValidator;
|
|
689
|
+
/**
|
|
690
|
+
* Run the validator and store results.
|
|
691
|
+
*/
|
|
692
|
+
passes(): Promise<boolean>;
|
|
693
|
+
/**
|
|
694
|
+
* Opposite of passes()
|
|
695
|
+
*/
|
|
696
|
+
fails(): Promise<boolean>;
|
|
697
|
+
/**
|
|
698
|
+
* Throw if validation fails, else return executed data
|
|
699
|
+
*
|
|
700
|
+
* @throws ValidationException if validation fails
|
|
701
|
+
*/
|
|
702
|
+
validate(): Promise<Record<string, any>>;
|
|
703
|
+
/**
|
|
704
|
+
* Run the validator's rules against its data.
|
|
705
|
+
* @param bagName
|
|
706
|
+
* @returns
|
|
707
|
+
*/
|
|
708
|
+
validateWithBag(bagName: string): Promise<Record<string, any>>;
|
|
709
|
+
/**
|
|
710
|
+
* Stop validation on first failure.
|
|
711
|
+
*/
|
|
712
|
+
stopOnFirstFailure(): this;
|
|
713
|
+
/**
|
|
714
|
+
* Get the data that passed validation.
|
|
715
|
+
*/
|
|
716
|
+
validatedData(): Record<string, any>;
|
|
717
|
+
/**
|
|
718
|
+
* Return all validated input.
|
|
719
|
+
*/
|
|
720
|
+
validated(): Partial<D>;
|
|
721
|
+
/**
|
|
722
|
+
* Return a portion of validated input
|
|
723
|
+
*/
|
|
724
|
+
safe(): {
|
|
725
|
+
only: (keys: string[]) => Partial<D>;
|
|
726
|
+
except: (keys: string[]) => Partial<D>;
|
|
727
|
+
};
|
|
728
|
+
/**
|
|
729
|
+
* Get the message container for the validator.
|
|
730
|
+
*/
|
|
731
|
+
messages(): Promise<Partial<Record<MessagesForRules<R>, string>>>;
|
|
732
|
+
/**
|
|
733
|
+
* Add an after validation callback.
|
|
734
|
+
*
|
|
735
|
+
* @param callback
|
|
736
|
+
*/
|
|
737
|
+
after<C extends ((validator: IValidator<D, R>) => void) | BaseValidationRuleClass>(callback: C | C[]): this;
|
|
738
|
+
/**
|
|
739
|
+
* Get all errors.
|
|
740
|
+
*/
|
|
741
|
+
errors(): IMessageBag;
|
|
742
|
+
errorBag(): string;
|
|
743
|
+
/**
|
|
744
|
+
* Reset validator with new data.
|
|
745
|
+
*/
|
|
746
|
+
setData(data: D): this;
|
|
747
|
+
/**
|
|
748
|
+
* Set validation rules.
|
|
749
|
+
*/
|
|
750
|
+
setRules(rules: R): this;
|
|
751
|
+
/**
|
|
752
|
+
* Add a single rule to existing rules.
|
|
753
|
+
*/
|
|
754
|
+
addRule(key: DotPaths<D>, rule: ValidationRuleSet): this;
|
|
755
|
+
/**
|
|
756
|
+
* Merge additional rules.
|
|
757
|
+
*/
|
|
758
|
+
mergeRules(rules: Record<string, string>): this;
|
|
759
|
+
/**
|
|
760
|
+
* Get current data.
|
|
761
|
+
*/
|
|
762
|
+
getData(): Record<string, any>;
|
|
763
|
+
/**
|
|
764
|
+
* Get current rules.
|
|
765
|
+
*/
|
|
766
|
+
getRules(): R;
|
|
767
|
+
database(driver: IDatabaseDriver): this;
|
|
768
|
+
getDatabaseDriver(): IDatabaseDriver | undefined;
|
|
769
|
+
}
|
|
770
|
+
//#endregion
|
|
771
|
+
//#region src/Rules/password.d.ts
|
|
772
|
+
declare class Password$1 extends IRuleContract {
|
|
773
|
+
/**
|
|
774
|
+
* The validator performing the validation.
|
|
775
|
+
*/
|
|
776
|
+
private validator;
|
|
777
|
+
/**
|
|
778
|
+
* The minimum size of the password.
|
|
779
|
+
*/
|
|
780
|
+
private minLength;
|
|
781
|
+
/**
|
|
782
|
+
* The min amount of lower case letters required in the password
|
|
783
|
+
*/
|
|
784
|
+
private minLowerCase;
|
|
785
|
+
/**
|
|
786
|
+
* The min amount of uppercase letters required in the password
|
|
787
|
+
*/
|
|
788
|
+
private minUpperCase;
|
|
789
|
+
/**
|
|
790
|
+
* The min amount of letters required in the password
|
|
791
|
+
*/
|
|
792
|
+
private minLetters;
|
|
793
|
+
/**
|
|
794
|
+
* The min amount of letters required in the password
|
|
795
|
+
*/
|
|
796
|
+
private minNumbers;
|
|
797
|
+
/**
|
|
798
|
+
* The min amount of symbols required in the password
|
|
799
|
+
*/
|
|
800
|
+
private minSymbols;
|
|
801
|
+
/**
|
|
802
|
+
* Additional validation rules that should be merged into the default rules during validation.
|
|
803
|
+
*/
|
|
804
|
+
private customRules;
|
|
805
|
+
/**
|
|
806
|
+
* The callback that will generate the "default" version of the password rule.
|
|
807
|
+
*/
|
|
808
|
+
static defaultCallback: GenericCallable | Password$1;
|
|
809
|
+
/**
|
|
810
|
+
* Create a new instance of the password class
|
|
811
|
+
*/
|
|
812
|
+
static create(): Password$1;
|
|
813
|
+
/**
|
|
814
|
+
* Set the minimum length of the password
|
|
815
|
+
*/
|
|
816
|
+
min(min: number): Password$1;
|
|
817
|
+
/**
|
|
818
|
+
* Set the min amount of letters required in the password
|
|
819
|
+
*/
|
|
820
|
+
letters(letters?: number): Password$1;
|
|
821
|
+
/**
|
|
822
|
+
* Set the min amount of upper and lower case letters required in the password
|
|
823
|
+
*/
|
|
824
|
+
mixedCase(upperCase?: number, lowerCase?: number): Password$1;
|
|
825
|
+
/**
|
|
826
|
+
* Set the min amount of numbers required in the password
|
|
827
|
+
*/
|
|
828
|
+
numbers(numbers?: number): Password$1;
|
|
829
|
+
/**
|
|
830
|
+
* Set the min amount of symbols required in the password
|
|
831
|
+
*/
|
|
832
|
+
symbols(symbols?: number): Password$1;
|
|
833
|
+
/**
|
|
834
|
+
* Determine if the validation rule passes.
|
|
835
|
+
*/
|
|
836
|
+
passes(value: any, attribute: string): boolean;
|
|
837
|
+
/**
|
|
838
|
+
* Specify additional validation rules that should be merged with the default rules during validation.
|
|
839
|
+
*/
|
|
840
|
+
rules(rules: InitialRule[]): Password$1;
|
|
841
|
+
/**
|
|
842
|
+
* Get all the validation error messages related to the password
|
|
843
|
+
*/
|
|
844
|
+
getMessage(): object;
|
|
845
|
+
/**
|
|
846
|
+
* Set the validator instance used to validate the password
|
|
847
|
+
*/
|
|
848
|
+
setValidator(validator: BaseValidator): Password$1;
|
|
849
|
+
/**
|
|
850
|
+
* Set the default callback to be used for determining a password's default rules.
|
|
851
|
+
*/
|
|
852
|
+
static setDefault(callback?: GenericCallable | Password$1 | null): void;
|
|
853
|
+
/**
|
|
854
|
+
* Get the default configuration of the password rule.
|
|
855
|
+
*/
|
|
856
|
+
static default(): IRuleContract | Password$1;
|
|
857
|
+
}
|
|
858
|
+
//#endregion
|
|
859
|
+
//#region src/Rules/registerRule.d.ts
|
|
860
|
+
declare function register(rule: string, validate: (value: any, parameters?: string[], attribute?: string) => boolean | Promise<boolean>, replaceMessage?: (message: string, paramters: string[], data?: object, getDisplayableAttribute?: GenericCallable) => string): boolean;
|
|
861
|
+
declare function registerImplicit(rule: string, validate: (value: any, parameters?: string[] | number[], attribute?: string) => boolean | Promise<boolean>, replaceMessage?: (message: string, paramters: string[], data?: object, getDisplayableAttribute?: GenericCallable) => string): void;
|
|
862
|
+
//#endregion
|
|
863
|
+
//#region src/rule.d.ts
|
|
864
|
+
declare function requiredIf(callback: boolean | CallableFunction): RequiredIf;
|
|
865
|
+
declare function ruleIn(values: (string | number)[]): In;
|
|
866
|
+
declare function ruleNotIn(values: (string | number)[]): NotIn;
|
|
867
|
+
declare function regex(value: RegExp): Regex;
|
|
868
|
+
declare function notRegex(value: RegExp): Regex;
|
|
869
|
+
//#endregion
|
|
870
|
+
//#region src/Core.d.ts
|
|
871
|
+
declare class Password extends Password$1 {}
|
|
872
|
+
declare function make(data?: GenericObject, rules?: InitialRules, customMessages?: CustomMessages, customAttributes?: CustomAttributes): BaseValidator;
|
|
873
|
+
//#endregion
|
|
874
|
+
//#region src/Rules/IImplicitRule.d.ts
|
|
875
|
+
declare class IImplicitRule extends IRuleContract {
|
|
876
|
+
readonly __isImplicitRule = true;
|
|
877
|
+
}
|
|
878
|
+
//#endregion
|
|
879
|
+
//#region src/utilities/MessageBag.d.ts
|
|
880
|
+
declare class MessageBag implements IMessageBag {
|
|
881
|
+
/**
|
|
882
|
+
* All of the registered messages.
|
|
883
|
+
*/
|
|
884
|
+
protected messages: Record<string, string[]>;
|
|
885
|
+
/**
|
|
886
|
+
* Default format for message output.
|
|
887
|
+
*/
|
|
888
|
+
protected format: string;
|
|
889
|
+
/**
|
|
890
|
+
* Create a new message bag instance.
|
|
891
|
+
*/
|
|
892
|
+
constructor(messages?: Record<string, string[] | string>);
|
|
893
|
+
/**
|
|
894
|
+
* Get all message keys.
|
|
895
|
+
*/
|
|
896
|
+
keys(): string[];
|
|
897
|
+
/**
|
|
898
|
+
* Add a message.
|
|
899
|
+
*/
|
|
900
|
+
add(key: string, message: string): this;
|
|
901
|
+
/**
|
|
902
|
+
* Add a message conditionally.
|
|
903
|
+
*/
|
|
904
|
+
addIf(condition: boolean, key: string, message: string): this;
|
|
905
|
+
/**
|
|
906
|
+
* Check uniqueness of key/message pair.
|
|
907
|
+
*/
|
|
908
|
+
protected isUnique(key: string, message: string): boolean;
|
|
909
|
+
/**
|
|
910
|
+
* Merge another message source into this one.
|
|
911
|
+
*/
|
|
912
|
+
merge(messages: Record<string, string[]> | ValidationMessageProvider): this;
|
|
913
|
+
/**
|
|
914
|
+
* Determine if messages exist for all given keys.
|
|
915
|
+
*/
|
|
916
|
+
has(key: string | string[] | null): boolean;
|
|
917
|
+
/**
|
|
918
|
+
* Determine if messages exist for any given key.
|
|
919
|
+
*/
|
|
920
|
+
hasAny(keys?: string | string[]): boolean;
|
|
921
|
+
/**
|
|
922
|
+
* Determine if messages don't exist for given keys.
|
|
923
|
+
*/
|
|
924
|
+
missing(key: string | string[]): boolean;
|
|
925
|
+
/**
|
|
926
|
+
* Get the first message for a given key.
|
|
927
|
+
*/
|
|
928
|
+
first(key?: string | null, format?: string | null): string;
|
|
929
|
+
/**
|
|
930
|
+
* Get all messages for a given key.
|
|
931
|
+
*/
|
|
932
|
+
get(key: string, format?: string | null): string[] | Record<string, string[]>;
|
|
933
|
+
/**
|
|
934
|
+
* Wildcard key match.
|
|
935
|
+
*/
|
|
936
|
+
protected getMessagesForWildcardKey(key: string, format: string | null): Record<string, string[]>;
|
|
937
|
+
/**
|
|
938
|
+
* Get all messages.
|
|
939
|
+
*/
|
|
940
|
+
all(format?: string | null): string[];
|
|
941
|
+
/**
|
|
942
|
+
* Get unique messages.
|
|
943
|
+
*/
|
|
944
|
+
unique(format?: string | null): string[];
|
|
945
|
+
/**
|
|
946
|
+
* Remove messages for a key.
|
|
947
|
+
*/
|
|
948
|
+
forget(key: string): this;
|
|
949
|
+
/**
|
|
950
|
+
* Format an array of messages.
|
|
951
|
+
*/
|
|
952
|
+
protected transform(messages: string[], format: string, messageKey: string): string[];
|
|
953
|
+
/**
|
|
954
|
+
* Get proper format string.
|
|
955
|
+
*/
|
|
956
|
+
protected checkFormat(format?: string | null): string;
|
|
957
|
+
/**
|
|
958
|
+
* Get raw messages.
|
|
959
|
+
*/
|
|
960
|
+
messagesRaw(): Record<string, string[]>;
|
|
961
|
+
/**
|
|
962
|
+
* Alias for messagesRaw().
|
|
963
|
+
*/
|
|
964
|
+
getMessages(): Record<string, string[]>;
|
|
965
|
+
/**
|
|
966
|
+
* Return message bag instance.
|
|
967
|
+
*/
|
|
968
|
+
getMessageBag(): MessageBag;
|
|
969
|
+
/**
|
|
970
|
+
* Get format string.
|
|
971
|
+
*/
|
|
972
|
+
getFormat(): string;
|
|
973
|
+
/**
|
|
974
|
+
* Set default message format.
|
|
975
|
+
*/
|
|
976
|
+
setFormat(format?: string): this;
|
|
977
|
+
/**
|
|
978
|
+
* Empty checks.
|
|
979
|
+
*/
|
|
980
|
+
isEmpty(): boolean;
|
|
981
|
+
isNotEmpty(): boolean;
|
|
982
|
+
any(): boolean;
|
|
983
|
+
/**
|
|
984
|
+
* Count total messages.
|
|
985
|
+
*/
|
|
986
|
+
count(): number;
|
|
987
|
+
/**
|
|
988
|
+
* Array & JSON conversions.
|
|
989
|
+
*/
|
|
990
|
+
toArray(): Record<string, string[]>;
|
|
991
|
+
jsonSerialize(): any;
|
|
992
|
+
toJson(options?: number): string;
|
|
993
|
+
toPrettyJson(): string;
|
|
994
|
+
/**
|
|
995
|
+
* String representation.
|
|
996
|
+
*/
|
|
997
|
+
toString(): string;
|
|
998
|
+
}
|
|
999
|
+
//#endregion
|
|
1000
|
+
//#region src/Validator.d.ts
|
|
1001
|
+
declare class Validator<D extends Record<string, any> = any, R extends RulesForData<D> = RulesForData<D>> implements IValidator<D, R> {
|
|
1002
|
+
#private;
|
|
1003
|
+
private static defaultDatabaseDriver?;
|
|
1004
|
+
private data;
|
|
1005
|
+
private rules;
|
|
1006
|
+
private _errors;
|
|
1007
|
+
private passing;
|
|
1008
|
+
private executed;
|
|
1009
|
+
private instance?;
|
|
1010
|
+
private databaseDriver?;
|
|
1011
|
+
private errorBagName;
|
|
1012
|
+
private registeredCustomRules;
|
|
1013
|
+
private shouldStopOnFirstFailure;
|
|
1014
|
+
constructor(data: D, rules: R, messages?: Partial<Record<MessagesForRules<R>, string>>);
|
|
1015
|
+
/**
|
|
1016
|
+
* Validate the data and return the instance
|
|
1017
|
+
*/
|
|
1018
|
+
static make<D extends Record<string, any>, R extends RulesForData<D>>(data: D, rules: R, messages?: Partial<Record<MessagesForRules<R>, string>>): Validator<D, R>;
|
|
1019
|
+
static useDatabase(driver: IDatabaseDriver): typeof Validator;
|
|
1020
|
+
/**
|
|
1021
|
+
* Run the validator and store results.
|
|
1022
|
+
*/
|
|
1023
|
+
passes(): Promise<boolean>;
|
|
1024
|
+
/**
|
|
1025
|
+
* Opposite of passes()
|
|
1026
|
+
*/
|
|
1027
|
+
fails(): Promise<boolean>;
|
|
1028
|
+
/**
|
|
1029
|
+
* Throw if validation fails, else return executed data
|
|
1030
|
+
*
|
|
1031
|
+
* @throws ValidationException if validation fails
|
|
1032
|
+
*/
|
|
1033
|
+
validate(): Promise<Record<string, any>>;
|
|
1034
|
+
/**
|
|
1035
|
+
* Run the validator's rules against its data.
|
|
1036
|
+
* @param bagName
|
|
1037
|
+
* @returns
|
|
1038
|
+
*/
|
|
1039
|
+
validateWithBag(bagName: string): Promise<Record<string, any>>;
|
|
1040
|
+
/**
|
|
1041
|
+
* Stop validation on first failure.
|
|
1042
|
+
*/
|
|
1043
|
+
stopOnFirstFailure(): this;
|
|
1044
|
+
/**
|
|
1045
|
+
* Get the data that passed validation.
|
|
1046
|
+
*/
|
|
1047
|
+
validatedData(): Record<string, any>;
|
|
1048
|
+
/**
|
|
1049
|
+
* Return all validated input.
|
|
1050
|
+
*/
|
|
1051
|
+
validated(): Partial<D>;
|
|
1052
|
+
/**
|
|
1053
|
+
* Return a portion of validated input
|
|
1054
|
+
*/
|
|
1055
|
+
safe(): {
|
|
1056
|
+
only: (keys: string[]) => Partial<D>;
|
|
1057
|
+
except: (keys: string[]) => Partial<D>;
|
|
1058
|
+
};
|
|
1059
|
+
/**
|
|
1060
|
+
* Get the message container for the validator.
|
|
1061
|
+
*/
|
|
1062
|
+
messages(): Promise<Partial<Record<MessagesForRules<R>, string>>>;
|
|
1063
|
+
/**
|
|
1064
|
+
* Add an after validation callback.
|
|
1065
|
+
*
|
|
1066
|
+
* @param callback
|
|
1067
|
+
*/
|
|
1068
|
+
after<C extends ((validator: Validator<D, R>) => void) | BaseValidationRuleClass>(callback: C | C[]): this;
|
|
1069
|
+
/**
|
|
1070
|
+
* Get all errors.
|
|
1071
|
+
*/
|
|
1072
|
+
errors(): MessageBag;
|
|
1073
|
+
errorBag(): string;
|
|
1074
|
+
/**
|
|
1075
|
+
* Reset validator with new data.
|
|
1076
|
+
*/
|
|
1077
|
+
setData(data: D): this;
|
|
1078
|
+
/**
|
|
1079
|
+
* Set validation rules.
|
|
1080
|
+
*/
|
|
1081
|
+
setRules(rules: R): this;
|
|
1082
|
+
/**
|
|
1083
|
+
* Add a single rule to existing rules.
|
|
1084
|
+
*/
|
|
1085
|
+
addRule(key: DotPaths<D>, rule: ValidationRuleSet): this;
|
|
1086
|
+
/**
|
|
1087
|
+
* Merge additional rules.
|
|
1088
|
+
*/
|
|
1089
|
+
mergeRules(rules: Record<string, string>): this;
|
|
1090
|
+
/**
|
|
1091
|
+
* Get current data.
|
|
1092
|
+
*/
|
|
1093
|
+
getData(): Record<string, any>;
|
|
1094
|
+
/**
|
|
1095
|
+
* Get current rules.
|
|
1096
|
+
*/
|
|
1097
|
+
getRules(): R;
|
|
1098
|
+
database(driver: IDatabaseDriver): this;
|
|
1099
|
+
getDatabaseDriver(): IDatabaseDriver | undefined;
|
|
1100
|
+
/**
|
|
1101
|
+
* Bind all required services here.
|
|
1102
|
+
*/
|
|
1103
|
+
private bindServices;
|
|
1104
|
+
private execute;
|
|
1105
|
+
}
|
|
1106
|
+
//#endregion
|
|
1107
|
+
//#region src/ImplicitRule.d.ts
|
|
1108
|
+
declare abstract class ImplicitRule extends IImplicitRule {
|
|
1109
|
+
rules: ValidationRuleCallable[];
|
|
1110
|
+
/**
|
|
1111
|
+
* Run the validation rule.
|
|
1112
|
+
*/
|
|
1113
|
+
abstract validate(attribute: string, value: any, fail: (msg: string) => any): void;
|
|
1114
|
+
/**
|
|
1115
|
+
* Set the current validator.
|
|
1116
|
+
*/
|
|
1117
|
+
setValidator?(validator: Validator<any, any>): this;
|
|
1118
|
+
}
|
|
1119
|
+
//#endregion
|
|
1120
|
+
//#region src/Lang.d.ts
|
|
1121
|
+
declare class Lang {
|
|
1122
|
+
/**
|
|
1123
|
+
* Default lang to be used, when lang is not specified
|
|
1124
|
+
*/
|
|
1125
|
+
static defaultLang: string;
|
|
1126
|
+
/**
|
|
1127
|
+
* Determines the locale to be used when tu current one is not available
|
|
1128
|
+
*/
|
|
1129
|
+
static fallbackLang: string;
|
|
1130
|
+
/**
|
|
1131
|
+
* The existing langs that are supported by the library
|
|
1132
|
+
*/
|
|
1133
|
+
static existingLangs: string[];
|
|
1134
|
+
/**
|
|
1135
|
+
* Store the translations passed by the user
|
|
1136
|
+
*/
|
|
1137
|
+
static translations: GenericObject;
|
|
1138
|
+
/**
|
|
1139
|
+
* Stores the messages that are already loaded
|
|
1140
|
+
*/
|
|
1141
|
+
static messages: GenericObject;
|
|
1142
|
+
/**
|
|
1143
|
+
* Stores the default messages
|
|
1144
|
+
*/
|
|
1145
|
+
static defaultMessages: GenericObject;
|
|
1146
|
+
/**
|
|
1147
|
+
* Stores the fallback messages
|
|
1148
|
+
*/
|
|
1149
|
+
static fallbackMessages: GenericObject;
|
|
1150
|
+
/**
|
|
1151
|
+
* Get messages for lang
|
|
1152
|
+
*
|
|
1153
|
+
* @param lang
|
|
1154
|
+
* @returns
|
|
1155
|
+
*/
|
|
1156
|
+
static get(lang?: string): GenericObject;
|
|
1157
|
+
/**
|
|
1158
|
+
* Set the translation object passed by the user
|
|
1159
|
+
*
|
|
1160
|
+
* @param translations
|
|
1161
|
+
*/
|
|
1162
|
+
static setTranslationObject(translations: GenericObject): void;
|
|
1163
|
+
/**
|
|
1164
|
+
* Set the default lang that should be used. And assign the default messages
|
|
1165
|
+
*
|
|
1166
|
+
* @param lang
|
|
1167
|
+
*/
|
|
1168
|
+
static setDefaultLang(lang: string): void;
|
|
1169
|
+
/**
|
|
1170
|
+
* Set the fallback lang to be used. And assign the fallback messages
|
|
1171
|
+
*
|
|
1172
|
+
* @param lang
|
|
1173
|
+
*/
|
|
1174
|
+
static setFallbackLang(lang: string): void;
|
|
1175
|
+
/**
|
|
1176
|
+
* Get the default language
|
|
1177
|
+
*
|
|
1178
|
+
* @returns
|
|
1179
|
+
*/
|
|
1180
|
+
static getDefaultLang(): string;
|
|
1181
|
+
/**
|
|
1182
|
+
* Load the messages based on the specified language
|
|
1183
|
+
*
|
|
1184
|
+
* @param lang
|
|
1185
|
+
* @returns
|
|
1186
|
+
*/
|
|
1187
|
+
static load(lang: string): void;
|
|
1188
|
+
}
|
|
1189
|
+
//#endregion
|
|
1190
|
+
//#region src/Providers/ValidationServiceProvider.d.ts
|
|
1191
|
+
/**
|
|
1192
|
+
* Service provider for Validation utilities
|
|
1193
|
+
*/
|
|
1194
|
+
declare class ValidationServiceProvider {
|
|
1195
|
+
private app;
|
|
1196
|
+
registeredCommands?: (new (app: any, kernel: any) => any)[];
|
|
1197
|
+
static priority: number;
|
|
1198
|
+
constructor(app: any);
|
|
1199
|
+
/**
|
|
1200
|
+
* Register URL services in the container
|
|
1201
|
+
*/
|
|
1202
|
+
register(): void;
|
|
1203
|
+
/**
|
|
1204
|
+
* Boot URL services
|
|
1205
|
+
*/
|
|
1206
|
+
boot(): void;
|
|
1207
|
+
}
|
|
1208
|
+
//#endregion
|
|
1209
|
+
//#region src/ValidationRule.d.ts
|
|
1210
|
+
declare abstract class ValidationRule<D extends Record<string, any> = any, R extends RulesForData<D> = any> extends IRuleContract implements IValidationRule {
|
|
1211
|
+
rules: ValidationRuleCallable[];
|
|
1212
|
+
private passing;
|
|
1213
|
+
/**
|
|
1214
|
+
* Run the validation rule.
|
|
1215
|
+
*/
|
|
1216
|
+
abstract validate(attribute: string, value: any, fail: (msg: string) => any): void;
|
|
1217
|
+
/**
|
|
1218
|
+
* Set the current validator.
|
|
1219
|
+
*/
|
|
1220
|
+
setValidator?(validator: Validator<D, R>): this;
|
|
1221
|
+
/**
|
|
1222
|
+
* Set the data under validation.
|
|
1223
|
+
*/
|
|
1224
|
+
setData(_data: Record<string, any>): this;
|
|
1225
|
+
passes(value: any, attribute: string): boolean | Promise<boolean>;
|
|
1226
|
+
}
|
|
1227
|
+
//#endregion
|
|
1228
|
+
//#region src/Rules/ExtendedRules.d.ts
|
|
1229
|
+
declare class ExtendedRules extends ValidationRule {
|
|
1230
|
+
/**
|
|
1231
|
+
* The validator instance.
|
|
1232
|
+
*/
|
|
1233
|
+
protected validator: Validator<any, any>;
|
|
1234
|
+
setValidator(validator: Validator<any, any>): this;
|
|
1235
|
+
private resolveTarget;
|
|
1236
|
+
rules: ValidationRuleCallable[];
|
|
1237
|
+
validate(): void;
|
|
1238
|
+
}
|
|
1239
|
+
//#endregion
|
|
1240
|
+
//#region src/utilities/build.d.ts
|
|
1241
|
+
declare function buildValidationMethodName(rule: string): string;
|
|
1242
|
+
//#endregion
|
|
1243
|
+
//#region src/utilities/date.d.ts
|
|
1244
|
+
/**
|
|
1245
|
+
* Convert value to date instance
|
|
1246
|
+
*/
|
|
1247
|
+
declare function toDate(value: any): Date | null;
|
|
1248
|
+
//#endregion
|
|
1249
|
+
//#region src/utilities/formatMessages.d.ts
|
|
1250
|
+
/**
|
|
1251
|
+
* Get the validation message for an attribute and rule.
|
|
1252
|
+
*/
|
|
1253
|
+
declare function getMessage(attributes: string[], rule: string, value: any, customMessages: CustomMessages, hasNumericRule: boolean, lang: string): string;
|
|
1254
|
+
/**
|
|
1255
|
+
* Convert a string to snake case.
|
|
1256
|
+
*/
|
|
1257
|
+
declare function toSnakeCase(string: string): string;
|
|
1258
|
+
/**
|
|
1259
|
+
* Get the formatted name of the attribute
|
|
1260
|
+
*/
|
|
1261
|
+
declare function getFormattedAttribute(attribute: string): string;
|
|
1262
|
+
/**
|
|
1263
|
+
* Get the combinations of keys from a main key. For example if the main key is 'user.info.name',
|
|
1264
|
+
* the combination will be [user.info.name, info.name, name]
|
|
1265
|
+
*/
|
|
1266
|
+
declare function getKeyCombinations(key: string): string[];
|
|
1267
|
+
//#endregion
|
|
1268
|
+
//#region src/utilities/general.d.ts
|
|
1269
|
+
/**
|
|
1270
|
+
* Get the size of a value based on its type
|
|
1271
|
+
*/
|
|
1272
|
+
declare function getSize(value: any, hasNumericRule?: boolean): number;
|
|
1273
|
+
/**
|
|
1274
|
+
* Check if two values are of the same type
|
|
1275
|
+
*/
|
|
1276
|
+
declare function sameType(value: any, otherValue: any): boolean;
|
|
1277
|
+
/**
|
|
1278
|
+
* Check if Value is an Ineteger
|
|
1279
|
+
*/
|
|
1280
|
+
declare function isInteger(value: any): boolean;
|
|
1281
|
+
/**
|
|
1282
|
+
* Check if the value can be considered as rule
|
|
1283
|
+
*/
|
|
1284
|
+
declare function isRule(value: any): boolean;
|
|
1285
|
+
/**
|
|
1286
|
+
* Check if the array contain any potentiel valid rule
|
|
1287
|
+
*/
|
|
1288
|
+
declare function isArrayOfRules(values: any[]): boolean;
|
|
1289
|
+
/**
|
|
1290
|
+
* Check if the rule is related to size
|
|
1291
|
+
*/
|
|
1292
|
+
declare function isSizeRule(rule: string): boolean;
|
|
1293
|
+
/**
|
|
1294
|
+
* Check if rule implies that the field is required
|
|
1295
|
+
*/
|
|
1296
|
+
declare function isImplicitRule(rule: TRule): boolean;
|
|
1297
|
+
/**
|
|
1298
|
+
* Add a new implicit rule
|
|
1299
|
+
*/
|
|
1300
|
+
declare function addImplicitRule(rule: string): void;
|
|
1301
|
+
/**
|
|
1302
|
+
* Returns the numeric rules
|
|
1303
|
+
*/
|
|
1304
|
+
declare function getNumericRules(): string[];
|
|
1305
|
+
/**
|
|
1306
|
+
* Check if the rule is numeric
|
|
1307
|
+
*/
|
|
1308
|
+
declare function isNumericRule(rule: string): boolean;
|
|
1309
|
+
/**
|
|
1310
|
+
* Determine if a comparison passes between the given values.
|
|
1311
|
+
*/
|
|
1312
|
+
declare function compare(first: any, second: any, operator: string, strict?: boolean): boolean;
|
|
1313
|
+
/**
|
|
1314
|
+
* Convert the given values to boolean if they are string "true" / "false".
|
|
1315
|
+
*/
|
|
1316
|
+
declare function convertValuesToBoolean(values: string[]): (string | boolean)[];
|
|
1317
|
+
/**
|
|
1318
|
+
* Convert the given values to numbers if they are numbers in a string "1", "2"
|
|
1319
|
+
*/
|
|
1320
|
+
declare function convertValuesToNumber(values: string[]): (string | number)[];
|
|
1321
|
+
/**
|
|
1322
|
+
* Convert the given values to null if they have null values in a string "null", "NULL"
|
|
1323
|
+
*/
|
|
1324
|
+
declare function convertValuesToNull(values: string[]): (string | null)[];
|
|
1325
|
+
//#endregion
|
|
1326
|
+
//#region src/utilities/helpers.d.ts
|
|
1327
|
+
/**
|
|
1328
|
+
* Pluralizes a word based on the count.
|
|
1329
|
+
*
|
|
1330
|
+
* @param word
|
|
1331
|
+
* @param count
|
|
1332
|
+
* @returns
|
|
1333
|
+
*/
|
|
1334
|
+
declare const plural: (word: string, count: number) => string;
|
|
1335
|
+
//#endregion
|
|
1336
|
+
//#region src/utilities/object.d.ts
|
|
1337
|
+
/**
|
|
1338
|
+
* Get value at path of object. If the resolved value is undifined, the returned result will be undefined
|
|
1339
|
+
*
|
|
1340
|
+
* @param obj
|
|
1341
|
+
* @param path
|
|
1342
|
+
* @returns
|
|
1343
|
+
*/
|
|
1344
|
+
declare function deepFind(obj: GenericObject, path: string): any;
|
|
1345
|
+
/**
|
|
1346
|
+
* Set value at path of object.
|
|
1347
|
+
*
|
|
1348
|
+
* @param target
|
|
1349
|
+
* @param path
|
|
1350
|
+
* @param value
|
|
1351
|
+
*/
|
|
1352
|
+
declare function deepSet(target: any, path: string | string[], value: any): void;
|
|
1353
|
+
/**
|
|
1354
|
+
* Flatten a multi-dimensional associative array with dots.
|
|
1355
|
+
*
|
|
1356
|
+
* @param obj
|
|
1357
|
+
* @param ignoreRulesArray
|
|
1358
|
+
* @param withBaseObjectType
|
|
1359
|
+
* @returns
|
|
1360
|
+
*/
|
|
1361
|
+
declare function dotify(obj: GenericObject, ignoreRulesArray?: boolean, withBaseObjectType?: boolean): GenericObject;
|
|
1362
|
+
/**
|
|
1363
|
+
* Check if the value is an object
|
|
1364
|
+
*
|
|
1365
|
+
* @param value
|
|
1366
|
+
* @returns
|
|
1367
|
+
*/
|
|
1368
|
+
declare function isObject(value: any): any;
|
|
1369
|
+
/**
|
|
1370
|
+
* Deeply merge nested objects
|
|
1371
|
+
*
|
|
1372
|
+
* @param target
|
|
1373
|
+
* @param source
|
|
1374
|
+
* @returns
|
|
1375
|
+
*/
|
|
1376
|
+
declare function mergeDeep(target: GenericObject, source: GenericObject): GenericObject;
|
|
1377
|
+
/**
|
|
1378
|
+
* Check if objects are deep equal
|
|
1379
|
+
*
|
|
1380
|
+
* @param firstParam
|
|
1381
|
+
* @param secondParam
|
|
1382
|
+
* @returns
|
|
1383
|
+
*/
|
|
1384
|
+
declare function deepEqual(firstParam: GenericObject, secondParam: GenericObject): boolean;
|
|
1385
|
+
//#endregion
|
|
1386
|
+
//#region src/ValidationException.d.ts
|
|
1387
|
+
declare class ValidationException extends Error {
|
|
1388
|
+
validator: Validator<any, any>;
|
|
1389
|
+
response?: any;
|
|
1390
|
+
status: number;
|
|
1391
|
+
errorBag: string;
|
|
1392
|
+
redirectTo?: string;
|
|
1393
|
+
name: string;
|
|
1394
|
+
constructor(validator: Validator<any, any>, response?: any, errorBag?: string);
|
|
1395
|
+
/**
|
|
1396
|
+
* Send a custom response body for this exception
|
|
1397
|
+
*
|
|
1398
|
+
* @param request
|
|
1399
|
+
* @returns
|
|
1400
|
+
*/
|
|
1401
|
+
toResponse(): {
|
|
1402
|
+
message: string;
|
|
1403
|
+
errors: Record<string, string[]>;
|
|
1404
|
+
};
|
|
1405
|
+
/**
|
|
1406
|
+
* Create a new validation exception from a plain array of messages.
|
|
1407
|
+
*/
|
|
1408
|
+
static withMessages(messages: Record<string, string[] | string>): ValidationException;
|
|
1409
|
+
/**
|
|
1410
|
+
* Create a readable summary message from the validation errors.
|
|
1411
|
+
*/
|
|
1412
|
+
protected static summarize(validator: Validator<any, any>): string;
|
|
1413
|
+
/**
|
|
1414
|
+
* Get all of the validation error messages.
|
|
1415
|
+
*/
|
|
1416
|
+
errors(): Record<string, string[]>;
|
|
1417
|
+
/**
|
|
1418
|
+
* Set the HTTP status code to be used for the response.
|
|
1419
|
+
*/
|
|
1420
|
+
setStatus(status: number): this;
|
|
1421
|
+
/**
|
|
1422
|
+
* Set the error bag on the exception.
|
|
1423
|
+
*/
|
|
1424
|
+
setErrorBag(errorBag: string): this;
|
|
1425
|
+
/**
|
|
1426
|
+
* Set the URL to redirect to on a validation error.
|
|
1427
|
+
*/
|
|
1428
|
+
setRedirectTo(url: string): this;
|
|
1429
|
+
/**
|
|
1430
|
+
* Get the underlying response instance.
|
|
1431
|
+
*/
|
|
1432
|
+
getResponse(): any;
|
|
1433
|
+
}
|
|
1434
|
+
//#endregion
|
|
1435
|
+
export { BaseValidationRuleClass, BaseValidator, CustomAttributes, CustomErrors, CustomMessages, CustomValidationRules, DotPaths, ErrorBag, ErrorMessage, Errors, ExtendedRules, ExtractRules, FieldMessages, GenericCallable, GenericObject, IDatabaseDriver, IMessageBag, IValidationRule, IValidator, ImplicitAttributes, ImplicitRule, InitialRule, InitialRules, Lang, MessageBag, Messages, MessagesForRules, ParamableValidationRuleName, Password, PlainRuleName, ReplaceAttributeInterface, Rules, RulesForData, TRule, ValidationCallback, ValidationDataInterface, ValidationDatabaseExistsInput, ValidationException, ValidationMessageProvider, ValidationRule, ValidationRuleCallable, ValidationRuleName, ValidationRuleParserInterface, ValidationRuleSet, ValidationServiceProvider, Validator, addImplicitRule, buildValidationMethodName, compare, convertValuesToBoolean, convertValuesToNull, convertValuesToNumber, deepEqual, deepFind, deepSet, dotify, getFormattedAttribute, getKeyCombinations, getMessage, getNumericRules, getSize, isArrayOfRules, isImplicitRule, isInteger, isNumericRule, isObject, isRule, isSizeRule, make, mergeDeep, notRegex, plural, regex, register, registerImplicit, requiredIf, ruleIn, ruleNotIn, sameType, toDate, toSnakeCase };
|