@regle/core 0.1.7 → 0.1.8
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.cjs +1 -1663
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +1 -1657
- package/package.json +7 -4
package/dist/index.d.cts
CHANGED
|
@@ -74,7 +74,7 @@ interface LocalRegleBehaviourOptions<TState extends Record<string, any>, TRules
|
|
|
74
74
|
externalErrors?: MaybeRef<TExternal>;
|
|
75
75
|
validationGroups?: (fields: RegleStatus<TState, TRules>['$fields']) => TValidationGroups;
|
|
76
76
|
}
|
|
77
|
-
type RegleValidationGroupEntry = RegleFieldStatus<any, any
|
|
77
|
+
type RegleValidationGroupEntry = RegleFieldStatus<any, any>;
|
|
78
78
|
interface RegleValidationGroupOutput {
|
|
79
79
|
$invalid: boolean;
|
|
80
80
|
$error: boolean;
|
|
@@ -377,17 +377,17 @@ type RegleStatus<TState extends Record<string, any> = Record<string, any>, TRule
|
|
|
377
377
|
/**
|
|
378
378
|
* @public
|
|
379
379
|
*/
|
|
380
|
-
type InferRegleStatusType<TRule extends RegleCollectionRuleDecl | RegleRuleDecl | ReglePartialValidationTree<any>, TState extends Record<PropertyKey, any> = any, TKey extends PropertyKey = string> = TRule extends RegleCollectionRuleDefinition<any, any> ? NonNullable<TState[TKey]> extends Array<Record<string, any> | any> ? ExtractFromGetter<TRule['$each']> extends RegleRuleDecl | ReglePartialValidationTree<any> ? RegleCollectionStatus<ExtractFromGetter<TRule['$each']>,
|
|
380
|
+
type InferRegleStatusType<TRule extends RegleCollectionRuleDecl | RegleRuleDecl | ReglePartialValidationTree<any>, TState extends Record<PropertyKey, any> = any, TKey extends PropertyKey = string> = TRule extends RegleCollectionRuleDefinition<any, any> ? NonNullable<TState[TKey]> extends Array<Record<string, any> | any> ? ExtractFromGetter<TRule['$each']> extends RegleRuleDecl | ReglePartialValidationTree<any> ? RegleCollectionStatus<TState[TKey], ExtractFromGetter<TRule['$each']>, TRule> : never : RegleFieldStatus<TState[TKey], TRule> : TRule extends ReglePartialValidationTree<any> ? NonNullable<TState[TKey]> extends Array<any> ? RegleCommonStatus<TState[TKey]> : NonNullable<TState[TKey]> extends Record<PropertyKey, any> ? RegleStatus<TState[TKey], TRule> : RegleFieldStatus<TState[TKey], TRule> : RegleFieldStatus<TState[TKey], TRule>;
|
|
381
381
|
/**
|
|
382
382
|
* @public
|
|
383
383
|
*/
|
|
384
|
-
interface RegleFieldStatus<TRules extends RegleFormPropertyType<any, Partial<AllRulesDeclarations>> = Record<string, any
|
|
385
|
-
$value: UnwrapNestedRefs<TState
|
|
384
|
+
interface RegleFieldStatus<TState extends any = unknown, TRules extends RegleFormPropertyType<any, Partial<AllRulesDeclarations>> = Record<string, any>> extends RegleCommonStatus<TState> {
|
|
385
|
+
$value: UnwrapNestedRefs<TState>;
|
|
386
386
|
readonly $errors: string[];
|
|
387
387
|
readonly $silentErrors: string[];
|
|
388
388
|
readonly $externalErrors?: string[];
|
|
389
389
|
readonly $rules: {
|
|
390
|
-
readonly [TRuleKey in keyof Omit<TRules, '$each' | keyof FieldRegleBehaviourOptions>]: RegleRuleStatus<TState
|
|
390
|
+
readonly [TRuleKey in keyof Omit<TRules, '$each' | keyof FieldRegleBehaviourOptions>]: RegleRuleStatus<TState, TRules[TRuleKey] extends RegleRuleDefinition<any, infer TParams, any> ? TParams : [], TRules[TRuleKey] extends RegleRuleDefinition<any, any, any, infer TMetadata> ? TMetadata : TRules[TRuleKey] extends InlineRuleDeclaration<any, any[], infer TMetadata> ? TMetadata extends Promise<infer P> ? P : TMetadata : never>;
|
|
391
391
|
};
|
|
392
392
|
}
|
|
393
393
|
/**
|
|
@@ -429,9 +429,9 @@ type RegleRuleStatus<TValue = any, TParams extends any[] = any[], TMetadata exte
|
|
|
429
429
|
/**
|
|
430
430
|
* @public
|
|
431
431
|
*/
|
|
432
|
-
interface RegleCollectionStatus<TRules extends RegleRuleDecl | ReglePartialValidationTree<any
|
|
432
|
+
interface RegleCollectionStatus<TState extends any[] = any[], TRules extends RegleRuleDecl | ReglePartialValidationTree<any> = Record<string, any>, TFieldRule extends RegleCollectionRuleDecl<any, any> = never> extends Omit<RegleFieldStatus<TState, TRules>, '$errors' | '$silentErrors'> {
|
|
433
433
|
readonly $each: Array<InferRegleStatusType<NonNullable<TRules>, NonNullable<TState>, number>>;
|
|
434
|
-
readonly $field: RegleFieldStatus<
|
|
434
|
+
readonly $field: RegleFieldStatus<TState, TFieldRule>;
|
|
435
435
|
readonly $errors: RegleErrorTree<TRules>;
|
|
436
436
|
readonly $silentErrors: RegleErrorTree<TRules>;
|
|
437
437
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -74,7 +74,7 @@ interface LocalRegleBehaviourOptions<TState extends Record<string, any>, TRules
|
|
|
74
74
|
externalErrors?: MaybeRef<TExternal>;
|
|
75
75
|
validationGroups?: (fields: RegleStatus<TState, TRules>['$fields']) => TValidationGroups;
|
|
76
76
|
}
|
|
77
|
-
type RegleValidationGroupEntry = RegleFieldStatus<any, any
|
|
77
|
+
type RegleValidationGroupEntry = RegleFieldStatus<any, any>;
|
|
78
78
|
interface RegleValidationGroupOutput {
|
|
79
79
|
$invalid: boolean;
|
|
80
80
|
$error: boolean;
|
|
@@ -377,17 +377,17 @@ type RegleStatus<TState extends Record<string, any> = Record<string, any>, TRule
|
|
|
377
377
|
/**
|
|
378
378
|
* @public
|
|
379
379
|
*/
|
|
380
|
-
type InferRegleStatusType<TRule extends RegleCollectionRuleDecl | RegleRuleDecl | ReglePartialValidationTree<any>, TState extends Record<PropertyKey, any> = any, TKey extends PropertyKey = string> = TRule extends RegleCollectionRuleDefinition<any, any> ? NonNullable<TState[TKey]> extends Array<Record<string, any> | any> ? ExtractFromGetter<TRule['$each']> extends RegleRuleDecl | ReglePartialValidationTree<any> ? RegleCollectionStatus<ExtractFromGetter<TRule['$each']>,
|
|
380
|
+
type InferRegleStatusType<TRule extends RegleCollectionRuleDecl | RegleRuleDecl | ReglePartialValidationTree<any>, TState extends Record<PropertyKey, any> = any, TKey extends PropertyKey = string> = TRule extends RegleCollectionRuleDefinition<any, any> ? NonNullable<TState[TKey]> extends Array<Record<string, any> | any> ? ExtractFromGetter<TRule['$each']> extends RegleRuleDecl | ReglePartialValidationTree<any> ? RegleCollectionStatus<TState[TKey], ExtractFromGetter<TRule['$each']>, TRule> : never : RegleFieldStatus<TState[TKey], TRule> : TRule extends ReglePartialValidationTree<any> ? NonNullable<TState[TKey]> extends Array<any> ? RegleCommonStatus<TState[TKey]> : NonNullable<TState[TKey]> extends Record<PropertyKey, any> ? RegleStatus<TState[TKey], TRule> : RegleFieldStatus<TState[TKey], TRule> : RegleFieldStatus<TState[TKey], TRule>;
|
|
381
381
|
/**
|
|
382
382
|
* @public
|
|
383
383
|
*/
|
|
384
|
-
interface RegleFieldStatus<TRules extends RegleFormPropertyType<any, Partial<AllRulesDeclarations>> = Record<string, any
|
|
385
|
-
$value: UnwrapNestedRefs<TState
|
|
384
|
+
interface RegleFieldStatus<TState extends any = unknown, TRules extends RegleFormPropertyType<any, Partial<AllRulesDeclarations>> = Record<string, any>> extends RegleCommonStatus<TState> {
|
|
385
|
+
$value: UnwrapNestedRefs<TState>;
|
|
386
386
|
readonly $errors: string[];
|
|
387
387
|
readonly $silentErrors: string[];
|
|
388
388
|
readonly $externalErrors?: string[];
|
|
389
389
|
readonly $rules: {
|
|
390
|
-
readonly [TRuleKey in keyof Omit<TRules, '$each' | keyof FieldRegleBehaviourOptions>]: RegleRuleStatus<TState
|
|
390
|
+
readonly [TRuleKey in keyof Omit<TRules, '$each' | keyof FieldRegleBehaviourOptions>]: RegleRuleStatus<TState, TRules[TRuleKey] extends RegleRuleDefinition<any, infer TParams, any> ? TParams : [], TRules[TRuleKey] extends RegleRuleDefinition<any, any, any, infer TMetadata> ? TMetadata : TRules[TRuleKey] extends InlineRuleDeclaration<any, any[], infer TMetadata> ? TMetadata extends Promise<infer P> ? P : TMetadata : never>;
|
|
391
391
|
};
|
|
392
392
|
}
|
|
393
393
|
/**
|
|
@@ -429,9 +429,9 @@ type RegleRuleStatus<TValue = any, TParams extends any[] = any[], TMetadata exte
|
|
|
429
429
|
/**
|
|
430
430
|
* @public
|
|
431
431
|
*/
|
|
432
|
-
interface RegleCollectionStatus<TRules extends RegleRuleDecl | ReglePartialValidationTree<any
|
|
432
|
+
interface RegleCollectionStatus<TState extends any[] = any[], TRules extends RegleRuleDecl | ReglePartialValidationTree<any> = Record<string, any>, TFieldRule extends RegleCollectionRuleDecl<any, any> = never> extends Omit<RegleFieldStatus<TState, TRules>, '$errors' | '$silentErrors'> {
|
|
433
433
|
readonly $each: Array<InferRegleStatusType<NonNullable<TRules>, NonNullable<TState>, number>>;
|
|
434
|
-
readonly $field: RegleFieldStatus<
|
|
434
|
+
readonly $field: RegleFieldStatus<TState, TFieldRule>;
|
|
435
435
|
readonly $errors: RegleErrorTree<TRules>;
|
|
436
436
|
readonly $silentErrors: RegleErrorTree<TRules>;
|
|
437
437
|
}
|