@regle/core 0.0.1 → 0.0.3
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/README.md +0 -0
- package/dist/index.cjs +91 -16637
- package/dist/index.d.cts +4 -23
- package/dist/index.d.ts +4 -23
- package/dist/index.js +78 -16636
- package/package.json +3 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as vue from 'vue';
|
|
2
|
-
import { MaybeRef
|
|
2
|
+
import { MaybeRef } from 'vue';
|
|
3
3
|
|
|
4
4
|
type ArrayElement<T> = T extends Array<infer U> ? U : never;
|
|
5
5
|
|
|
@@ -16,12 +16,11 @@ interface RegleRuleInit<TValue extends any, TParams extends any[] = []> {
|
|
|
16
16
|
type: string;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
type DefaultValidators = {
|
|
20
20
|
maxLength: RegleRuleWithParamsDefinition<string, [count: number]>;
|
|
21
21
|
required: RegleRuleDefinition<unknown, []>;
|
|
22
22
|
requiredIf: RegleRuleWithParamsDefinition<unknown, [condition: boolean]>;
|
|
23
23
|
};
|
|
24
|
-
type DefaultValidators = typeof defaultValidators;
|
|
25
24
|
|
|
26
25
|
type ParamDecl<T = any> = MaybeRef<T> | (() => T);
|
|
27
26
|
type CreateFn<T extends any[]> = (...args: T) => any;
|
|
@@ -185,29 +184,11 @@ declare function createRule<TValue extends any, TParams extends any[] = []>(defi
|
|
|
185
184
|
* @param customRules
|
|
186
185
|
*/
|
|
187
186
|
declare function defineCustomValidators<TCustomRules extends Partial<AllRulesDeclarations>>(customRules: () => TCustomRules): {
|
|
188
|
-
useRegle: <TState extends Record<string, any>, TRules extends ReglePartialValidationTree<TState, CustomRulesDeclarationTree & {
|
|
189
|
-
maxLength: RegleRuleWithParamsDefinition<string, [count: number]>;
|
|
190
|
-
required: RegleRuleDefinition<unknown, []>;
|
|
191
|
-
requiredIf: RegleRuleWithParamsDefinition<unknown, [condition: boolean]>;
|
|
192
|
-
} & TCustomRules>>(state: vue.Ref<TState>, rulesFactory: vue.ComputedRef<TRules> | (() => TRules)) => {
|
|
187
|
+
useRegle: <TState extends Record<string, any>, TRules extends ReglePartialValidationTree<TState, CustomRulesDeclarationTree & DefaultValidators & TCustomRules>>(state: vue.Ref<TState>, rulesFactory: vue.ComputedRef<TRules> | (() => TRules)) => {
|
|
193
188
|
state: vue.Ref<TState>;
|
|
194
189
|
$regle: vue.Ref<RegleStatus<TState, TRules>>;
|
|
195
190
|
errors: RegleErrorTree<TRules>;
|
|
196
191
|
};
|
|
197
192
|
};
|
|
198
193
|
|
|
199
|
-
|
|
200
|
-
declare function withMessage<TValue extends any, TParams extends any[]>(rule: RegleRuleWithParamsDefinition<TValue, TParams>, newMessage: string | ((value: TValue, ...args: TParams) => string)): RegleRuleWithParamsDefinition<TValue, TParams>;
|
|
201
|
-
declare function withMessage<TValue extends any, TParams extends any[]>(rule: RegleRuleDefinition<TValue, TParams>, newMessage: string | ((value: TValue, ...args: TParams) => string)): RegleRuleDefinition<TValue, TParams>;
|
|
202
|
-
|
|
203
|
-
declare function withAsync<TParams extends (Ref<unknown> | (() => unknown))[]>(rule: InlineRuleDeclaration<any>, depsArray: [...TParams]): RegleRuleDefinition<any>;
|
|
204
|
-
|
|
205
|
-
declare function isEmpty(value: unknown): value is null | undefined;
|
|
206
|
-
|
|
207
|
-
declare const required: RegleRuleDefinition<unknown, []>;
|
|
208
|
-
|
|
209
|
-
declare const maxLength: RegleRuleWithParamsDefinition<string, [count: number]>;
|
|
210
|
-
|
|
211
|
-
declare const requiredIf: RegleRuleWithParamsDefinition<unknown, [condition: boolean]>;
|
|
212
|
-
|
|
213
|
-
export { AllRulesDeclarations, CustomRulesDeclarationTree, DataType, FormRuleDeclaration, InferRegleRule, InferRegleStatusType, InlineRuleDeclaration, InternalRuleType, ParamDecl, PossibleRegleErrors, PossibleRegleFieldStatus, PossibleRegleStatus, RegleCollectionErrors, RegleCollectionRuleDecl, RegleCollectionRuleDefinition, RegleCollectionStatus, RegleCommonStatus, RegleErrorTree, RegleFieldStatus, RegleFormPropertyType, RegleInternalRuleDefs, ReglePartialValidationTree, RegleRuleDecl, RegleRuleDefinition, RegleRuleDefinitionProcessor, RegleRuleInit, RegleRuleRaw, RegleRuleStatus, RegleRuleWithParamsDefinition, RegleSoftRuleStatus, RegleStatus, RegleUniversalParams, RegleValidationErrors, UnwrapRegleUniversalParams, createRule, defineCustomValidators, isEmpty, maxLength, required, requiredIf, withAsync, withMessage };
|
|
194
|
+
export { AllRulesDeclarations, CustomRulesDeclarationTree, DataType, FormRuleDeclaration, InferRegleRule, InferRegleStatusType, InlineRuleDeclaration, InternalRuleType, ParamDecl, PossibleRegleErrors, PossibleRegleFieldStatus, PossibleRegleStatus, RegleCollectionErrors, RegleCollectionRuleDecl, RegleCollectionRuleDefinition, RegleCollectionStatus, RegleCommonStatus, RegleErrorTree, RegleFieldStatus, RegleFormPropertyType, RegleInternalRuleDefs, ReglePartialValidationTree, RegleRuleDecl, RegleRuleDefinition, RegleRuleDefinitionProcessor, RegleRuleInit, RegleRuleRaw, RegleRuleStatus, RegleRuleWithParamsDefinition, RegleSoftRuleStatus, RegleStatus, RegleUniversalParams, RegleValidationErrors, UnwrapRegleUniversalParams, createRule, defineCustomValidators };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as vue from 'vue';
|
|
2
|
-
import { MaybeRef
|
|
2
|
+
import { MaybeRef } from 'vue';
|
|
3
3
|
|
|
4
4
|
type ArrayElement<T> = T extends Array<infer U> ? U : never;
|
|
5
5
|
|
|
@@ -16,12 +16,11 @@ interface RegleRuleInit<TValue extends any, TParams extends any[] = []> {
|
|
|
16
16
|
type: string;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
type DefaultValidators = {
|
|
20
20
|
maxLength: RegleRuleWithParamsDefinition<string, [count: number]>;
|
|
21
21
|
required: RegleRuleDefinition<unknown, []>;
|
|
22
22
|
requiredIf: RegleRuleWithParamsDefinition<unknown, [condition: boolean]>;
|
|
23
23
|
};
|
|
24
|
-
type DefaultValidators = typeof defaultValidators;
|
|
25
24
|
|
|
26
25
|
type ParamDecl<T = any> = MaybeRef<T> | (() => T);
|
|
27
26
|
type CreateFn<T extends any[]> = (...args: T) => any;
|
|
@@ -185,29 +184,11 @@ declare function createRule<TValue extends any, TParams extends any[] = []>(defi
|
|
|
185
184
|
* @param customRules
|
|
186
185
|
*/
|
|
187
186
|
declare function defineCustomValidators<TCustomRules extends Partial<AllRulesDeclarations>>(customRules: () => TCustomRules): {
|
|
188
|
-
useRegle: <TState extends Record<string, any>, TRules extends ReglePartialValidationTree<TState, CustomRulesDeclarationTree & {
|
|
189
|
-
maxLength: RegleRuleWithParamsDefinition<string, [count: number]>;
|
|
190
|
-
required: RegleRuleDefinition<unknown, []>;
|
|
191
|
-
requiredIf: RegleRuleWithParamsDefinition<unknown, [condition: boolean]>;
|
|
192
|
-
} & TCustomRules>>(state: vue.Ref<TState>, rulesFactory: vue.ComputedRef<TRules> | (() => TRules)) => {
|
|
187
|
+
useRegle: <TState extends Record<string, any>, TRules extends ReglePartialValidationTree<TState, CustomRulesDeclarationTree & DefaultValidators & TCustomRules>>(state: vue.Ref<TState>, rulesFactory: vue.ComputedRef<TRules> | (() => TRules)) => {
|
|
193
188
|
state: vue.Ref<TState>;
|
|
194
189
|
$regle: vue.Ref<RegleStatus<TState, TRules>>;
|
|
195
190
|
errors: RegleErrorTree<TRules>;
|
|
196
191
|
};
|
|
197
192
|
};
|
|
198
193
|
|
|
199
|
-
|
|
200
|
-
declare function withMessage<TValue extends any, TParams extends any[]>(rule: RegleRuleWithParamsDefinition<TValue, TParams>, newMessage: string | ((value: TValue, ...args: TParams) => string)): RegleRuleWithParamsDefinition<TValue, TParams>;
|
|
201
|
-
declare function withMessage<TValue extends any, TParams extends any[]>(rule: RegleRuleDefinition<TValue, TParams>, newMessage: string | ((value: TValue, ...args: TParams) => string)): RegleRuleDefinition<TValue, TParams>;
|
|
202
|
-
|
|
203
|
-
declare function withAsync<TParams extends (Ref<unknown> | (() => unknown))[]>(rule: InlineRuleDeclaration<any>, depsArray: [...TParams]): RegleRuleDefinition<any>;
|
|
204
|
-
|
|
205
|
-
declare function isEmpty(value: unknown): value is null | undefined;
|
|
206
|
-
|
|
207
|
-
declare const required: RegleRuleDefinition<unknown, []>;
|
|
208
|
-
|
|
209
|
-
declare const maxLength: RegleRuleWithParamsDefinition<string, [count: number]>;
|
|
210
|
-
|
|
211
|
-
declare const requiredIf: RegleRuleWithParamsDefinition<unknown, [condition: boolean]>;
|
|
212
|
-
|
|
213
|
-
export { AllRulesDeclarations, CustomRulesDeclarationTree, DataType, FormRuleDeclaration, InferRegleRule, InferRegleStatusType, InlineRuleDeclaration, InternalRuleType, ParamDecl, PossibleRegleErrors, PossibleRegleFieldStatus, PossibleRegleStatus, RegleCollectionErrors, RegleCollectionRuleDecl, RegleCollectionRuleDefinition, RegleCollectionStatus, RegleCommonStatus, RegleErrorTree, RegleFieldStatus, RegleFormPropertyType, RegleInternalRuleDefs, ReglePartialValidationTree, RegleRuleDecl, RegleRuleDefinition, RegleRuleDefinitionProcessor, RegleRuleInit, RegleRuleRaw, RegleRuleStatus, RegleRuleWithParamsDefinition, RegleSoftRuleStatus, RegleStatus, RegleUniversalParams, RegleValidationErrors, UnwrapRegleUniversalParams, createRule, defineCustomValidators, isEmpty, maxLength, required, requiredIf, withAsync, withMessage };
|
|
194
|
+
export { AllRulesDeclarations, CustomRulesDeclarationTree, DataType, FormRuleDeclaration, InferRegleRule, InferRegleStatusType, InlineRuleDeclaration, InternalRuleType, ParamDecl, PossibleRegleErrors, PossibleRegleFieldStatus, PossibleRegleStatus, RegleCollectionErrors, RegleCollectionRuleDecl, RegleCollectionRuleDefinition, RegleCollectionStatus, RegleCommonStatus, RegleErrorTree, RegleFieldStatus, RegleFormPropertyType, RegleInternalRuleDefs, ReglePartialValidationTree, RegleRuleDecl, RegleRuleDefinition, RegleRuleDefinitionProcessor, RegleRuleInit, RegleRuleRaw, RegleRuleStatus, RegleRuleWithParamsDefinition, RegleSoftRuleStatus, RegleStatus, RegleUniversalParams, RegleValidationErrors, UnwrapRegleUniversalParams, createRule, defineCustomValidators };
|