kanun 1.0.9 → 1.0.10
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/dist/index.d.ts +6 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -119,6 +119,7 @@ declare class RequiredIf extends BaseRule {
|
|
|
119
119
|
//#region src/Contracts/ValidationRuleName.d.ts
|
|
120
120
|
type ValidationRuleAutocompleteKind = 'plain' | 'paramable';
|
|
121
121
|
interface ValidationRuleAutocompleteMap {}
|
|
122
|
+
interface ValidationRuleOutputTypeMap {}
|
|
122
123
|
/**
|
|
123
124
|
* Backward-compatible alias for older plugin augmentations.
|
|
124
125
|
*/
|
|
@@ -775,7 +776,9 @@ type ExtractRules<R> = R extends string ? R extends `${infer Head}|${infer Tail}
|
|
|
775
776
|
type ValidatedData<T> = { [K in keyof T]: T[K] };
|
|
776
777
|
type RuleOutputKey<T extends string> = T extends `${infer Root}.*${string}` ? Root : T extends `${infer Root}.${string}` ? Root : T;
|
|
777
778
|
type RuleOutputKeys<R extends Record<string, any>> = RuleOutputKey<Extract<keyof R, string>>;
|
|
778
|
-
type
|
|
779
|
+
type RuleOutputOverride<R> = 'files' extends ExtractRules<R> ? ('files' extends keyof ValidationRuleOutputTypeMap ? ValidationRuleOutputTypeMap['files'] : never) : ValidationRuleOutputTypeMap[Extract<ExtractRules<R>, keyof ValidationRuleOutputTypeMap>];
|
|
780
|
+
type FieldOutputValue<D extends Record<string, any>, K extends string, FieldRules> = K extends keyof D ? [RuleOutputOverride<FieldRules>] extends [never] ? D[K] : D[K] extends RuleOutputOverride<FieldRules> ? D[K] : RuleOutputOverride<FieldRules> : [RuleOutputOverride<FieldRules>] extends [never] ? any : RuleOutputOverride<FieldRules>;
|
|
781
|
+
type ValidatedByRules<D extends Record<string, any>, R extends RulesForData<D>> = ValidatedData<{ [K in RuleOutputKeys<R>]: FieldOutputValue<D, K, K extends keyof R ? R[K] : never> }>;
|
|
779
782
|
/**
|
|
780
783
|
* Flatten data structure into dot-notation keys
|
|
781
784
|
* including wildcards (*) for arrays.
|
|
@@ -1200,7 +1203,7 @@ declare class Validator<D extends Record<string, any> = any, R extends RulesForD
|
|
|
1200
1203
|
* @param bagName
|
|
1201
1204
|
* @returns
|
|
1202
1205
|
*/
|
|
1203
|
-
validateWithBag(bagName: string): Promise<{ [K_1 in Extract<
|
|
1206
|
+
validateWithBag(bagName: string): Promise<{ [K_1 in Extract<keyof R, string> extends infer T_1 ? T_1 extends Extract<keyof R, string> ? T_1 extends `${infer Root}.*${string}` ? Root : T_1 extends `${infer Root_1}.${string}` ? Root_1 : T_1 : never : never]: K_1 extends keyof D ? ["files" extends ExtractRules<K_1 extends keyof R ? R[K_1] : never> ? never : ValidationRuleOutputTypeMap[Extract<ExtractRules<K_1 extends keyof R ? R[K_1] : never>, never>]] extends [never] ? D[K_1] : D[K_1] extends ("files" extends ExtractRules<K_1 extends keyof R ? R[K_1] : never> ? never : ValidationRuleOutputTypeMap[Extract<ExtractRules<K_1 extends keyof R ? R[K_1] : never>, never>]) ? D[K_1] : "files" extends ExtractRules<K_1 extends keyof R ? R[K_1] : never> ? never : ValidationRuleOutputTypeMap[Extract<ExtractRules<K_1 extends keyof R ? R[K_1] : never>, never>] : ["files" extends ExtractRules<K_1 extends keyof R ? R[K_1] : never> ? never : ValidationRuleOutputTypeMap[Extract<ExtractRules<K_1 extends keyof R ? R[K_1] : never>, never>]] extends [never] ? any : "files" extends ExtractRules<K_1 extends keyof R ? R[K_1] : never> ? never : ValidationRuleOutputTypeMap[Extract<ExtractRules<K_1 extends keyof R ? R[K_1] : never>, never>] } extends infer T ? { [K in keyof T]: T[K] } : never>;
|
|
1204
1207
|
/**
|
|
1205
1208
|
* Stop validation on first failure.
|
|
1206
1209
|
*/
|
|
@@ -1639,4 +1642,4 @@ declare class ValidationException extends Error {
|
|
|
1639
1642
|
getResponse(): any;
|
|
1640
1643
|
}
|
|
1641
1644
|
//#endregion
|
|
1642
|
-
export { BaseValidationRuleClass, BaseValidator, CustomAttributes, CustomErrors, CustomMessages, CustomParamableValidationRuleName, CustomPlainRuleName, CustomValidationRuleNameMap, CustomValidationRules, DotPaths, ErrorBag, ErrorMessage, Errors, ExtendedRules, ExtractRules, FieldMessages, GenericCallable, GenericObject, IDatabaseDriver, IMessageBag, IValidationRule, IValidator, ImplicitAttributes, ImplicitRule, InitialRule, InitialRules, Lang, MessageBag, Messages, MessagesForRules, NestedStringMap, ParamableValidationRuleName, Password, PlainRuleName, ReplaceAttributeInterface, Rules, RulesForData, TRule, ValidatedByRules, ValidationCallback, ValidationDataInterface, ValidationDatabaseExistsInput, ValidationException, ValidationMessageProvider, ValidationRule, ValidationRuleAutocompleteKind, ValidationRuleAutocompleteMap, ValidationRuleCallable, ValidationRuleEntry, ValidationRuleName, ValidationRuleParserInterface, ValidationRuleSet, ValidationServiceProvider, ValidationValueInspector, Validator, ValidatorPlugin, ValidatorPluginApi, addImplicitRule, buildValidationMethodName, compare, convertValuesToBoolean, convertValuesToNull, convertValuesToNumber, deepEqual, deepFind, deepFindMessage, deepSet, definePlugin, dotify, getFormattedAttribute, getKeyCombinations, getMessage, getNumericRules, getSize, getValidationMessageType, getValidationSize, getValidationValueInspector, getValidatorContext, isArrayOfRules, isImplicitRule, isInteger, isNumericRule, isObject, isRule, isSizeRule, make, mergeDeep, notRegex, plural, regex, register, registerImplicit, registerValueInspector, requiredIf, ruleIn, ruleNotIn, runWithValidatorContext, sameType, toDate, toSnakeCase, usePlugin, useValidatorContext };
|
|
1645
|
+
export { BaseValidationRuleClass, BaseValidator, CustomAttributes, CustomErrors, CustomMessages, CustomParamableValidationRuleName, CustomPlainRuleName, CustomValidationRuleNameMap, CustomValidationRules, DotPaths, ErrorBag, ErrorMessage, Errors, ExtendedRules, ExtractRules, FieldMessages, GenericCallable, GenericObject, IDatabaseDriver, IMessageBag, IValidationRule, IValidator, ImplicitAttributes, ImplicitRule, InitialRule, InitialRules, Lang, MessageBag, Messages, MessagesForRules, NestedStringMap, ParamableValidationRuleName, Password, PlainRuleName, ReplaceAttributeInterface, Rules, RulesForData, TRule, ValidatedByRules, ValidationCallback, ValidationDataInterface, ValidationDatabaseExistsInput, ValidationException, ValidationMessageProvider, ValidationRule, ValidationRuleAutocompleteKind, ValidationRuleAutocompleteMap, ValidationRuleCallable, ValidationRuleEntry, ValidationRuleName, ValidationRuleOutputTypeMap, ValidationRuleParserInterface, ValidationRuleSet, ValidationServiceProvider, ValidationValueInspector, Validator, ValidatorPlugin, ValidatorPluginApi, addImplicitRule, buildValidationMethodName, compare, convertValuesToBoolean, convertValuesToNull, convertValuesToNumber, deepEqual, deepFind, deepFindMessage, deepSet, definePlugin, dotify, getFormattedAttribute, getKeyCombinations, getMessage, getNumericRules, getSize, getValidationMessageType, getValidationSize, getValidationValueInspector, getValidatorContext, isArrayOfRules, isImplicitRule, isInteger, isNumericRule, isObject, isRule, isSizeRule, make, mergeDeep, notRegex, plural, regex, register, registerImplicit, registerValueInspector, requiredIf, ruleIn, ruleNotIn, runWithValidatorContext, sameType, toDate, toSnakeCase, usePlugin, useValidatorContext };
|