@regle/core 1.4.0-beta.2 → 1.4.1-beta.1
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/regle-core.d.ts +131 -34
- package/dist/regle-core.js +205 -170
- package/dist/regle-core.min.js +1 -1
- package/package.json +2 -2
package/dist/regle-core.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as vue1 from "vue";
|
|
2
2
|
import { MaybeRef, MaybeRefOrGetter, Raw, Ref, UnwrapNestedRefs, UnwrapRef } from "vue";
|
|
3
3
|
|
|
4
4
|
//#region src/types/utils/misc.types.d.ts
|
|
@@ -7,6 +7,7 @@ type Maybe<T = any> = T | null | undefined;
|
|
|
7
7
|
type MaybeInput<T = any> = T | null | undefined;
|
|
8
8
|
type MaybeOutput<T = any> = T | undefined;
|
|
9
9
|
type MaybeReadonly<T> = T | Readonly<T>;
|
|
10
|
+
type NonUndefined<T> = Exclude<T, undefined>;
|
|
10
11
|
type PromiseReturn<T> = T extends Promise<infer U> ? U : T;
|
|
11
12
|
type MaybeGetter<T, V = any, TAdd extends Record<string, any> = {}> = T | ((value: Ref<V>, index: number) => T & TAdd);
|
|
12
13
|
type Unwrap<T extends MaybeRef<Record<string, any>>> = T extends Ref ? UnwrapRef<T> : UnwrapNestedRefs<T>;
|
|
@@ -331,6 +332,56 @@ const anyA = get(anyObject, 'a');
|
|
|
331
332
|
*/
|
|
332
333
|
type IsAny$1<T> = 0 extends 1 & NoInfer<T> ? true : false;
|
|
333
334
|
//#endregion
|
|
335
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/is-equal.d.ts
|
|
336
|
+
/**
|
|
337
|
+
Returns a boolean for whether the two given types are equal.
|
|
338
|
+
|
|
339
|
+
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
|
|
340
|
+
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
|
|
341
|
+
|
|
342
|
+
Use-cases:
|
|
343
|
+
- If you want to make a conditional branch based on the result of a comparison of two types.
|
|
344
|
+
|
|
345
|
+
@example
|
|
346
|
+
```
|
|
347
|
+
import type {IsEqual} from 'type-fest';
|
|
348
|
+
|
|
349
|
+
// This type returns a boolean for whether the given array includes the given item.
|
|
350
|
+
// `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
|
|
351
|
+
type Includes<Value extends readonly any[], Item> =
|
|
352
|
+
Value extends readonly [Value[0], ...infer rest]
|
|
353
|
+
? IsEqual<Value[0], Item> extends true
|
|
354
|
+
? true
|
|
355
|
+
: Includes<rest, Item>
|
|
356
|
+
: false;
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
@category Type Guard
|
|
360
|
+
@category Utilities
|
|
361
|
+
*/
|
|
362
|
+
type IsEqual<A, B> = (<G>() => G extends A & G | G ? 1 : 2) extends (<G>() => G extends B & G | G ? 1 : 2) ? true : false;
|
|
363
|
+
//#endregion
|
|
364
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/or.d.ts
|
|
365
|
+
/**
|
|
366
|
+
Returns a boolean for whether either of two given types are true.
|
|
367
|
+
|
|
368
|
+
Use-case: Constructing complex conditional types where multiple conditions must be satisfied.
|
|
369
|
+
|
|
370
|
+
@example
|
|
371
|
+
```
|
|
372
|
+
import type {Or} from 'type-fest';
|
|
373
|
+
|
|
374
|
+
Or<true, false>;
|
|
375
|
+
//=> true
|
|
376
|
+
|
|
377
|
+
Or<false, false>;
|
|
378
|
+
//=> false
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
@see {@link And}
|
|
382
|
+
*/
|
|
383
|
+
type Or<A extends boolean, B extends boolean> = [A, B][number] extends false ? false : true extends [IsEqual<A, true>, IsEqual<B, true>][number] ? true : never;
|
|
384
|
+
//#endregion
|
|
334
385
|
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/internal/keys.d.ts
|
|
335
386
|
/**
|
|
336
387
|
Disallows any of the given keys.
|
|
@@ -1731,9 +1782,9 @@ type NarrowVariant<TRoot extends {
|
|
|
1731
1782
|
}, TKey extends keyof TRoot, TValue extends (LazyJoinDiscriminatedUnions<Exclude<TRoot[TKey], RegleCollectionStatus<any, any, any> | RegleStatus<any, any, any>>> extends {
|
|
1732
1783
|
$value: infer V;
|
|
1733
1784
|
} ? V : unknown)> = Extract<TRoot, { [K in TKey]: RegleFieldStatus<TValue, any, any> }>;
|
|
1734
|
-
type MaybeVariantStatus<TState extends Record<string, any> | undefined = Record<string, any>, TRules extends ReglePartialRuleTree<NonNullable<TState>> = Record<string, any>, TShortcuts extends RegleShortcutDefinition = {}> = IsUnion<NonNullable<TState>> extends true ? Omit<RegleStatus<TState, TRules, TShortcuts>, '$fields'> & {
|
|
1785
|
+
type MaybeVariantStatus<TState extends Record<string, any> | undefined = Record<string, any>, TRules extends ReglePartialRuleTree<NonNullable<TState>> = Record<string, any>, TShortcuts extends RegleShortcutDefinition = {}> = IsUnion<NonNullable<TState>> extends true ? Omit<RegleStatus<TState, TRules, TShortcuts>, '$fields' | keyof RegleStatus<TState, TRules, TShortcuts>['$fields']> & {
|
|
1735
1786
|
$fields: ProcessChildrenFields<TState, TRules, TShortcuts>[keyof ProcessChildrenFields<TState, TRules, TShortcuts>];
|
|
1736
|
-
} : RegleStatus<TState, TRules, TShortcuts>;
|
|
1787
|
+
} & (HasNamedKeys<TState> extends true ? ProcessChildrenFields<TState, TRules, TShortcuts>[keyof ProcessChildrenFields<TState, TRules, TShortcuts>] : {}) : RegleStatus<TState, TRules, TShortcuts>;
|
|
1737
1788
|
type ProcessChildrenFields<TState extends Record<string, any> | undefined, TRules extends ReglePartialRuleTree<NonNullable<TState>>, TShortcuts extends RegleShortcutDefinition = {}> = { [TIndex in keyof TupleToPlainObj<UnionToTuple<TState>>]: TIndex extends `${infer TIndexInt extends number}` ? { [TKey in keyof UnionToTuple<TState>[TIndexInt] as IsEmptyObject<FindCorrespondingVariant<UnionToTuple<TState>[TIndexInt] extends Record<string, any> ? UnionToTuple<TState>[TIndexInt] : never, UnionToTuple<TRules>> extends [infer U] ? TKey extends keyof U ? U[TKey] : EmptyObject : EmptyObject> extends true ? TKey extends keyof TState ? TState[TKey] extends NonNullable<TState[TKey]> ? TKey : never : never : TKey]-?: InferRegleStatusType<FindCorrespondingVariant<UnionToTuple<TState>[TIndexInt] extends Record<string, any> ? UnionToTuple<TState>[TIndexInt] : never, UnionToTuple<TRules>> extends [infer U] ? TKey extends keyof U ? U[TKey] : EmptyObject : EmptyObject, NonNullable<UnionToTuple<TState>[TIndexInt]>, TKey, TShortcuts> } & { [TKey in keyof UnionToTuple<TState>[TIndexInt] as IsEmptyObject<FindCorrespondingVariant<UnionToTuple<TState>[TIndexInt] extends Record<string, any> ? UnionToTuple<TState>[TIndexInt] : never, UnionToTuple<TRules>> extends [infer U] ? TKey extends keyof U ? U[TKey] : EmptyObject : EmptyObject> extends true ? TKey extends keyof TState ? TState[TKey] extends NonNullable<TState[TKey]> ? never : TKey : TKey : never]?: InferRegleStatusType<FindCorrespondingVariant<UnionToTuple<TState>[TIndexInt] extends Record<string, any> ? UnionToTuple<TState>[TIndexInt] : never, UnionToTuple<TRules>> extends [infer U] ? TKey extends keyof U ? U[TKey] : EmptyObject : EmptyObject, NonNullable<UnionToTuple<TState>[TIndexInt]>, TKey, TShortcuts> } : {} };
|
|
1738
1789
|
type FindCorrespondingVariant<TState extends Record<string, any>, TRules extends any[]> = TRules extends [infer F, ...infer R] ? F extends ReglePartialRuleTree<TState> ? [F] : FindCorrespondingVariant<TState, R> : [];
|
|
1739
1790
|
type PossibleLiteralTypes<T extends Record<string, any>, TKey extends keyof T> = unknown extends T[TKey] ? {
|
|
@@ -1876,7 +1927,7 @@ type GetMaybeObjectValue<O extends Record<string, any>, K extends string> = K ex
|
|
|
1876
1927
|
/**
|
|
1877
1928
|
* Combine all union values to be able to get even the normally "never" values, act as an intersection type
|
|
1878
1929
|
*/
|
|
1879
|
-
type RetrieveUnionUnknownValues<T extends readonly any[], TKeys extends string> = T extends [infer F extends Record<string, any>, ...infer R] ? [{ [K in TKeys as GetMaybeObjectValue<F, K> extends
|
|
1930
|
+
type RetrieveUnionUnknownValues<T extends readonly any[], TKeys extends string> = T extends [infer F extends Record<string, any>, ...infer R] ? [{ [K in TKeys as GetMaybeObjectValue<F, K> extends NonUndefined<GetMaybeObjectValue<F, K>> ? never : K]?: GetMaybeObjectValue<F, K> } & { [K in TKeys as GetMaybeObjectValue<F, K> extends NonUndefined<GetMaybeObjectValue<F, K>> ? K : never]: GetMaybeObjectValue<F, K> }, ...RetrieveUnionUnknownValues<R, TKeys>] : [];
|
|
1880
1931
|
/**
|
|
1881
1932
|
* Get all possible keys from a union, even the ones present only on one union
|
|
1882
1933
|
*/
|
|
@@ -1897,6 +1948,7 @@ type EnumLike = {
|
|
|
1897
1948
|
type enumType<T extends Record<string, unknown>> = T[keyof T];
|
|
1898
1949
|
type UnwrapMaybeRef<T extends MaybeRef<any> | DeepReactiveState<any>> = T extends Ref<any> ? UnwrapRef<T> : UnwrapNestedRefs<T>;
|
|
1899
1950
|
type TupleToPlainObj<T> = { [I in keyof T & `${number}`]: T[I] };
|
|
1951
|
+
type HasNamedKeys<T> = { [K in keyof NonNullable<T>]: K extends string ? (string extends K ? never : K) : never }[keyof NonNullable<T>] extends never ? false : true;
|
|
1900
1952
|
//#endregion
|
|
1901
1953
|
//#region src/types/utils/mismatch.types.d.ts
|
|
1902
1954
|
type isDeepExact<TRules, TTree> = { [K in keyof TRules]-?: CheckDeepExact<NonNullable<TRules[K]>, K extends keyof JoinDiscriminatedUnions<TTree> ? NonNullable<JoinDiscriminatedUnions<TTree>[K]> : never> }[keyof TRules] extends true ? true : false;
|
|
@@ -2058,6 +2110,7 @@ interface RegleRuleCore<TValue extends any, TParams extends any[] = [], TAsync e
|
|
|
2058
2110
|
active?: RegleInitPropertyGetter<TValue, string | string[], TParams, TMetadata>;
|
|
2059
2111
|
tooltip?: RegleInitPropertyGetter<TValue, string | string[], TParams, TMetadata>;
|
|
2060
2112
|
type?: string;
|
|
2113
|
+
async?: boolean;
|
|
2061
2114
|
}
|
|
2062
2115
|
/**
|
|
2063
2116
|
* @internal
|
|
@@ -2233,16 +2286,24 @@ type RegleRoot<TState extends Record<string, any> = {}, TRules extends ReglePart
|
|
|
2233
2286
|
*/
|
|
2234
2287
|
$groups: { readonly [TKey in keyof TValidationGroups]: RegleValidationGroupOutput };
|
|
2235
2288
|
});
|
|
2289
|
+
type ProcessNestedFields<TState extends Record<string, any> | undefined, TRules extends ReglePartialRuleTree<NonNullable<TState>>, TShortcuts extends RegleShortcutDefinition = {}, TIsFields extends boolean = false> = Or<HasNamedKeys<TState>, TIsFields> extends true ? { readonly [TKey in keyof TState as TRules[TKey] extends NonNullable<TRules[TKey]> ? NonNullable<TRules[TKey]> extends RegleRuleDecl ? IsEmptyObject<TRules[TKey]> extends true ? TKey : never : never : TKey]: IsUnion<NonNullable<TRules[TKey]>> extends true ? ExtendOnlyRealRecord<TState[TKey]> extends true ? MaybeVariantStatus<NonNullable<TState>[TKey], NonNullable<TRules[TKey]>, TShortcuts> : InferRegleStatusType<NonNullable<TRules[TKey]>, NonNullable<TState>, TKey, TShortcuts> : InferRegleStatusType<NonNullable<TRules[TKey]>, NonNullable<TState>, TKey, TShortcuts> } & { readonly [TKey in keyof TState as TRules[TKey] extends NonNullable<TRules[TKey]> ? NonNullable<TRules[TKey]> extends RegleRuleDecl ? IsEmptyObject<TRules[TKey]> extends true ? never : TKey : TKey : never]-?: IsUnion<NonNullable<TRules[TKey]>> extends true ? ExtendOnlyRealRecord<TState[TKey]> extends true ? MaybeVariantStatus<NonNullable<TState>[TKey], NonNullable<TRules[TKey]>, TShortcuts> : InferRegleStatusType<NonNullable<TRules[TKey]>, NonNullable<TState>, TKey, TShortcuts> : InferRegleStatusType<NonNullable<TRules[TKey]>, NonNullable<TState>, TKey, TShortcuts> } : {};
|
|
2236
2290
|
/**
|
|
2237
2291
|
* @public
|
|
2238
2292
|
*/
|
|
2239
2293
|
type RegleStatus<TState extends Record<string, any> | undefined = Record<string, any>, TRules extends ReglePartialRuleTree<NonNullable<TState>> = Record<string, any>, TShortcuts extends RegleShortcutDefinition = {}> = RegleCommonStatus<TState> & {
|
|
2240
2294
|
/** Represents all the children of your object. You can access any nested child at any depth to get the relevant data you need for your form. */
|
|
2241
|
-
readonly $fields:
|
|
2295
|
+
readonly $fields: ProcessNestedFields<TState, TRules, TShortcuts, true>;
|
|
2296
|
+
/**
|
|
2297
|
+
* Collection of all the issues, collected for all children properties and nested forms.
|
|
2298
|
+
*
|
|
2299
|
+
* Only contains issues from properties where $dirty equals true.
|
|
2300
|
+
*/
|
|
2301
|
+
readonly $issues: RegleIssuesTree<TState>;
|
|
2242
2302
|
/**
|
|
2243
2303
|
* Collection of all the error messages, collected for all children properties and nested forms.
|
|
2244
2304
|
*
|
|
2245
|
-
* Only contains errors from properties where $dirty equals true.
|
|
2305
|
+
* Only contains errors from properties where $dirty equals true.
|
|
2306
|
+
* */
|
|
2246
2307
|
readonly $errors: RegleErrorTree<TState>;
|
|
2247
2308
|
/** Collection of all the error messages, collected for all children properties. */
|
|
2248
2309
|
readonly $silentErrors: RegleErrorTree<TState>;
|
|
@@ -2250,7 +2311,7 @@ type RegleStatus<TState extends Record<string, any> | undefined = Record<string,
|
|
|
2250
2311
|
$extractDirtyFields: (filterNullishValues?: boolean) => PartialDeep<TState>;
|
|
2251
2312
|
/** Sets all properties as dirty, triggering all rules. It returns a promise that will either resolve to false or a type safe copy of your form state. Values that had the required rule will be transformed into a non-nullable value (type only). */
|
|
2252
2313
|
$validate: () => Promise<RegleResult<JoinDiscriminatedUnions<TState>, TRules>>;
|
|
2253
|
-
} & ([TShortcuts['nested']] extends [never] ? {} : { [K in keyof TShortcuts['nested']]: ReturnType<NonNullable<TShortcuts['nested']>[K]> });
|
|
2314
|
+
} & ProcessNestedFields<TState, TRules, TShortcuts> & ([TShortcuts['nested']] extends [never] ? {} : { [K in keyof TShortcuts['nested']]: ReturnType<NonNullable<TShortcuts['nested']>[K]> });
|
|
2254
2315
|
/**
|
|
2255
2316
|
* @internal
|
|
2256
2317
|
* @reference {@link RegleStatus}
|
|
@@ -2259,6 +2320,7 @@ interface $InternalRegleStatus extends $InternalRegleCommonStatus {
|
|
|
2259
2320
|
$fields: {
|
|
2260
2321
|
[x: string]: $InternalRegleStatusType;
|
|
2261
2322
|
};
|
|
2323
|
+
readonly $issues: Record<string, $InternalRegleIssues>;
|
|
2262
2324
|
readonly $errors: Record<string, $InternalRegleErrors>;
|
|
2263
2325
|
readonly $silentErrors: Record<string, $InternalRegleErrors>;
|
|
2264
2326
|
$extractDirtyFields: (filterNullishValues?: boolean) => Record<string, any>;
|
|
@@ -2273,13 +2335,26 @@ type InferRegleStatusType<TRule extends RegleCollectionRuleDecl | RegleRuleDecl
|
|
|
2273
2335
|
* @reference {@link InferRegleStatusType}
|
|
2274
2336
|
*/
|
|
2275
2337
|
type $InternalRegleStatusType = $InternalRegleCollectionStatus | $InternalRegleStatus | $InternalRegleFieldStatus;
|
|
2276
|
-
|
|
2277
|
-
$property: string;
|
|
2278
|
-
$
|
|
2279
|
-
$
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
}
|
|
2338
|
+
type RegleFieldIssue<TRules extends RegleFormPropertyType<any, Partial<AllRulesDeclarations>> = EmptyObject> = {
|
|
2339
|
+
readonly $property: string;
|
|
2340
|
+
readonly $type?: string;
|
|
2341
|
+
readonly $message: string;
|
|
2342
|
+
} & (IsEmptyObject<TRules> extends true ? {
|
|
2343
|
+
readonly $rule: string;
|
|
2344
|
+
} : { [K in keyof ComputeFieldRules<any, TRules>]: ComputeFieldRules<any, TRules>[K] extends {
|
|
2345
|
+
$metadata: infer TMetadata;
|
|
2346
|
+
} ? K extends string ? {
|
|
2347
|
+
readonly $rule: K;
|
|
2348
|
+
} & (TMetadata extends boolean ? {
|
|
2349
|
+
readonly $rule: string;
|
|
2350
|
+
} : TMetadata) : {
|
|
2351
|
+
readonly $rule: string;
|
|
2352
|
+
} : {
|
|
2353
|
+
readonly $rule: string;
|
|
2354
|
+
} }[keyof ComputeFieldRules<any, TRules>]);
|
|
2355
|
+
type ComputeFieldRules<TState extends any, TRules extends RegleFormPropertyType<any, Partial<AllRulesDeclarations>>> = IsEmptyObject<TRules> extends true ? {
|
|
2356
|
+
readonly [x: string]: RegleRuleStatus<TState, any[], any>;
|
|
2357
|
+
} : { 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 : boolean> };
|
|
2283
2358
|
/**
|
|
2284
2359
|
* @public
|
|
2285
2360
|
*/
|
|
@@ -2295,13 +2370,13 @@ type RegleFieldStatus<TState extends any = any, TRules extends RegleFormProperty
|
|
|
2295
2370
|
/** Collection of all the error messages, collected for all children properties and nested forms. */
|
|
2296
2371
|
readonly $silentErrors: string[];
|
|
2297
2372
|
/**
|
|
2298
|
-
* Collect all metadata of validators, Only contains
|
|
2373
|
+
* Collect all metadata of validators, Only contains metadata from properties where $dirty equals true.
|
|
2299
2374
|
*/
|
|
2300
|
-
readonly $issues: RegleFieldIssue[];
|
|
2375
|
+
readonly $issues: RegleFieldIssue<TRules>[];
|
|
2301
2376
|
/**
|
|
2302
2377
|
* Collect all metadata of validators, including the error message.
|
|
2303
2378
|
*/
|
|
2304
|
-
readonly $silentIssues: RegleFieldIssue[];
|
|
2379
|
+
readonly $silentIssues: RegleFieldIssue<TRules>[];
|
|
2305
2380
|
/** Stores external errors of the current field */
|
|
2306
2381
|
readonly $externalErrors: string[];
|
|
2307
2382
|
/** Stores active tooltips messages of the current field */
|
|
@@ -2313,9 +2388,7 @@ type RegleFieldStatus<TState extends any = any, TRules extends RegleFormProperty
|
|
|
2313
2388
|
/** Sets all properties as dirty, triggering all rules. It returns a promise that will either resolve to false or a type safe copy of your form state. Values that had the required rule will be transformed into a non-nullable value (type only). */
|
|
2314
2389
|
$validate: () => Promise<RegleResult<TState, TRules>>;
|
|
2315
2390
|
/** This is reactive tree containing all the declared rules of your field. To know more about the rule properties check the rules properties section */
|
|
2316
|
-
readonly $rules:
|
|
2317
|
-
readonly [x: string]: RegleRuleStatus<TState, any[], any>;
|
|
2318
|
-
} : { 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 : boolean> };
|
|
2391
|
+
readonly $rules: ComputeFieldRules<TState, TRules>;
|
|
2319
2392
|
} & ([TShortcuts['fields']] extends [never] ? {} : { [K in keyof TShortcuts['fields']]: ReturnType<NonNullable<TShortcuts['fields']>[K]> });
|
|
2320
2393
|
/**
|
|
2321
2394
|
* @internal
|
|
@@ -2368,6 +2441,8 @@ interface RegleCommonStatus<TValue = any> {
|
|
|
2368
2441
|
readonly $ready: boolean;
|
|
2369
2442
|
/** Return the current key name of the field. */
|
|
2370
2443
|
readonly $name: string;
|
|
2444
|
+
/** Returns the current path of the rule (used internally for tracking) */
|
|
2445
|
+
readonly $path: string;
|
|
2371
2446
|
/** Id used to track collections items */
|
|
2372
2447
|
$id?: string;
|
|
2373
2448
|
/** A reference to the original validated model. It can be used to bind your form with v-model.*/
|
|
@@ -2464,6 +2539,12 @@ type RegleCollectionStatus<TState extends any[] = any[], TRules extends ReglePar
|
|
|
2464
2539
|
readonly $each: Array<InferRegleStatusType<NonNullable<TRules>, NonNullable<TState>, number, TShortcuts>>;
|
|
2465
2540
|
/** Represents the status of the collection itself. You can have validation rules on the array like minLength, this field represents the isolated status of the collection. */
|
|
2466
2541
|
readonly $self: RegleFieldStatus<TState, TFieldRule, TShortcuts>;
|
|
2542
|
+
/**
|
|
2543
|
+
* Collection of all the issues, collected for all children properties and nested forms.
|
|
2544
|
+
*
|
|
2545
|
+
* Only contains issues from properties where $dirty equals true.
|
|
2546
|
+
*/
|
|
2547
|
+
readonly $issues: RegleCollectionErrors<TState, true>;
|
|
2467
2548
|
/** Collection of all the error messages, collected for all children properties and nested forms.
|
|
2468
2549
|
*
|
|
2469
2550
|
* Only contains errors from properties where $dirty equals true. */
|
|
@@ -2479,9 +2560,10 @@ type RegleCollectionStatus<TState extends any[] = any[], TRules extends ReglePar
|
|
|
2479
2560
|
* @internal
|
|
2480
2561
|
* @reference {@link RegleCollectionStatus}
|
|
2481
2562
|
*/
|
|
2482
|
-
interface $InternalRegleCollectionStatus extends Omit<$InternalRegleStatus, '$fields' | '$errors' | '$silentErrors'> {
|
|
2563
|
+
interface $InternalRegleCollectionStatus extends Omit<$InternalRegleStatus, '$fields' | '$issues' | '$errors' | '$silentErrors'> {
|
|
2483
2564
|
readonly $self: $InternalRegleFieldStatus;
|
|
2484
2565
|
readonly $each: Array<$InternalRegleStatusType>;
|
|
2566
|
+
readonly $issues: $InternalRegleCollectionIssues;
|
|
2485
2567
|
readonly $errors: $InternalRegleCollectionErrors;
|
|
2486
2568
|
readonly $silentErrors: $InternalRegleCollectionErrors;
|
|
2487
2569
|
readonly $externalErrors?: string[];
|
|
@@ -2490,16 +2572,17 @@ interface $InternalRegleCollectionStatus extends Omit<$InternalRegleStatus, '$fi
|
|
|
2490
2572
|
}
|
|
2491
2573
|
//#endregion
|
|
2492
2574
|
//#region src/types/rules/rule.errors.types.d.ts
|
|
2493
|
-
type RegleErrorTree<TState = MaybeRef<Record<string, any> | any[]
|
|
2575
|
+
type RegleErrorTree<TState = MaybeRef<Record<string, any> | any[]>, TIssue extends boolean = false> = { readonly [K in keyof JoinDiscriminatedUnions<UnwrapMaybeRef<TState>>]: RegleValidationErrors<JoinDiscriminatedUnions<UnwrapMaybeRef<TState>>[K], false, TIssue> };
|
|
2576
|
+
type RegleIssuesTree<TState = MaybeRef<Record<string, any> | any[]>> = { readonly [K in keyof JoinDiscriminatedUnions<UnwrapMaybeRef<TState>>]: RegleValidationErrors<JoinDiscriminatedUnions<UnwrapMaybeRef<TState>>[K], false, true> };
|
|
2494
2577
|
type RegleExternalErrorTree<TState = MaybeRef<Record<string, any> | any[]>> = { readonly [K in keyof JoinDiscriminatedUnions<UnwrapMaybeRef<TState>>]?: RegleValidationErrors<JoinDiscriminatedUnions<UnwrapMaybeRef<TState>>[K], true> };
|
|
2495
2578
|
type RegleExternalSchemaErrorTree<TState = MaybeRef<Record<string, any> | any[]>> = { readonly [K in keyof JoinDiscriminatedUnions<UnwrapMaybeRef<TState>>]?: RegleValidationErrors<JoinDiscriminatedUnions<UnwrapMaybeRef<TState>>[K], true, true> };
|
|
2496
|
-
type RegleValidationErrors<TState extends Record<string, any> | any[] | unknown = never, TExternal extends boolean = false, TIssue extends boolean = false> = NonNullable<TState> extends Array<infer U extends Record<string, any>> ? ExtendOnlyRealRecord<U> extends true ? TExternal extends false ? RegleCollectionErrors<U> : RegleExternalCollectionErrors<U> : TIssue extends true ? RegleFieldIssue[] : string[] : NonNullable<TState> extends Date | File ? TIssue extends true ? RegleFieldIssue[] : string[] : NonNullable<TState> extends Record<string, any> ? TExternal extends false ? RegleErrorTree<TState> : RegleExternalErrorTree<TState> : TIssue extends true ? RegleFieldIssue[] : string[];
|
|
2579
|
+
type RegleValidationErrors<TState extends Record<string, any> | any[] | unknown = never, TExternal extends boolean = false, TIssue extends boolean = false> = NonNullable<TState> extends Array<infer U extends Record<string, any>> ? ExtendOnlyRealRecord<U> extends true ? TExternal extends false ? RegleCollectionErrors<U, TIssue> : RegleExternalCollectionErrors<U, TIssue> : TIssue extends true ? RegleFieldIssue[] : string[] : NonNullable<TState> extends Date | File ? TIssue extends true ? RegleFieldIssue[] : string[] : NonNullable<TState> extends Record<string, any> ? TExternal extends false ? RegleErrorTree<TState, TIssue> : RegleExternalErrorTree<TState> : TIssue extends true ? RegleFieldIssue[] : string[];
|
|
2497
2580
|
type RegleCollectionErrors<TState extends Record<string, any>, TIssue extends boolean = false> = {
|
|
2498
|
-
readonly $self: string[];
|
|
2581
|
+
readonly $self: TIssue extends true ? RegleFieldIssue[] : string[];
|
|
2499
2582
|
readonly $each: RegleValidationErrors<TState, false, TIssue>[];
|
|
2500
2583
|
};
|
|
2501
2584
|
type RegleExternalCollectionErrors<TState extends Record<string, any>, TIssue extends boolean = false> = {
|
|
2502
|
-
readonly $self?: string[];
|
|
2585
|
+
readonly $self?: TIssue extends true ? RegleFieldIssue[] : string[];
|
|
2503
2586
|
readonly $each?: RegleValidationErrors<TState, true, TIssue>[];
|
|
2504
2587
|
};
|
|
2505
2588
|
/** @internal */
|
|
@@ -2511,6 +2594,14 @@ type $InternalRegleErrorTree = {
|
|
|
2511
2594
|
[x: string]: $InternalRegleErrors;
|
|
2512
2595
|
};
|
|
2513
2596
|
type $InternalRegleErrors = $InternalRegleCollectionErrors | string[] | $InternalRegleErrorTree;
|
|
2597
|
+
type $InternalRegleIssuesTree = {
|
|
2598
|
+
[x: string]: $InternalRegleIssues;
|
|
2599
|
+
};
|
|
2600
|
+
type $InternalRegleIssues = $InternalRegleCollectionIssues | RegleFieldIssue[] | $InternalRegleIssuesTree;
|
|
2601
|
+
type $InternalRegleCollectionIssues = {
|
|
2602
|
+
readonly $self?: RegleFieldIssue[];
|
|
2603
|
+
readonly $each?: $InternalRegleIssues[];
|
|
2604
|
+
};
|
|
2514
2605
|
//#endregion
|
|
2515
2606
|
//#region src/types/rules/compatibility.rules.d.ts
|
|
2516
2607
|
interface SuperCompatibleRegle {
|
|
@@ -2524,15 +2615,17 @@ type SuperCompatibleRegleRoot = SuperCompatibleRegleStatus & {
|
|
|
2524
2615
|
$validate: () => Promise<SuperCompatibleRegleResult>;
|
|
2525
2616
|
};
|
|
2526
2617
|
type SuperCompatibleRegleResult = $InternalRegleResult;
|
|
2527
|
-
|
|
2528
|
-
$fields: {
|
|
2529
|
-
[x: string]:
|
|
2618
|
+
type SuperCompatibleRegleStatus = {
|
|
2619
|
+
readonly $fields: {
|
|
2620
|
+
[x: string]: any;
|
|
2530
2621
|
};
|
|
2622
|
+
readonly $issues: Record<string, RegleValidationErrors<any, false, true>>;
|
|
2531
2623
|
readonly $errors: Record<string, RegleValidationErrors<any, false>>;
|
|
2532
2624
|
readonly $silentErrors: Record<string, RegleValidationErrors<any, false>>;
|
|
2533
2625
|
$extractDirtyFields: (filterNullishValues?: boolean) => Record<string, any>;
|
|
2534
2626
|
$validate?: () => Promise<SuperCompatibleRegleResult>;
|
|
2535
|
-
|
|
2627
|
+
[x: string]: any;
|
|
2628
|
+
};
|
|
2536
2629
|
type SuperCompatibleRegleRuleStatus = Omit<$InternalRegleRuleStatus, '$haveAsync' | '$validating' | '$fieldDirty' | '$fieldInvalid' | '$fieldPending' | '$fieldCorrect' | '$fieldError' | '$unwatch' | '$watch' | '$maybePending'>;
|
|
2537
2630
|
type SuperCompatibleRegleCommonStatus = Omit<RegleCommonStatus, '$pending'> & {
|
|
2538
2631
|
$pending?: boolean;
|
|
@@ -2542,15 +2635,18 @@ interface SuperCompatibleRegleFieldStatus extends SuperCompatibleRegleCommonStat
|
|
|
2542
2635
|
$silentValue: any;
|
|
2543
2636
|
readonly $rules: Record<string, SuperCompatibleRegleRuleStatus>;
|
|
2544
2637
|
readonly $externalErrors?: string[];
|
|
2638
|
+
readonly $issues: RegleFieldIssue[];
|
|
2639
|
+
readonly $silentIssues: RegleFieldIssue[];
|
|
2545
2640
|
readonly $errors: string[];
|
|
2546
2641
|
readonly $inactive: boolean;
|
|
2547
2642
|
readonly $silentErrors: string[];
|
|
2548
2643
|
$extractDirtyFields: (filterNullishValues?: boolean) => any;
|
|
2549
2644
|
$validate?: () => Promise<SuperCompatibleRegleResult>;
|
|
2550
2645
|
}
|
|
2551
|
-
interface SuperCompatibleRegleCollectionStatus extends Omit<SuperCompatibleRegleStatus, '$fields' | '$errors' | '$silentErrors'> {
|
|
2646
|
+
interface SuperCompatibleRegleCollectionStatus extends Omit<SuperCompatibleRegleStatus, '$fields' | '$issues' | '$errors' | '$silentErrors'> {
|
|
2552
2647
|
readonly $self: SuperCompatibleRegleFieldStatus;
|
|
2553
2648
|
readonly $each: Array<SuperCompatibleRegleStatus | SuperCompatibleRegleFieldStatus>;
|
|
2649
|
+
readonly $issues: SuperCompatibleRegleCollectionIssues;
|
|
2554
2650
|
readonly $errors: SuperCompatibleRegleCollectionErrors;
|
|
2555
2651
|
readonly $silentErrors: SuperCompatibleRegleCollectionErrors;
|
|
2556
2652
|
readonly $externalErrors?: string[];
|
|
@@ -2558,6 +2654,7 @@ interface SuperCompatibleRegleCollectionStatus extends Omit<SuperCompatibleRegle
|
|
|
2558
2654
|
$validate?: () => Promise<SuperCompatibleRegleResult>;
|
|
2559
2655
|
}
|
|
2560
2656
|
type SuperCompatibleRegleCollectionErrors = $InternalRegleCollectionErrors;
|
|
2657
|
+
type SuperCompatibleRegleCollectionIssues = $InternalRegleCollectionIssues;
|
|
2561
2658
|
//#endregion
|
|
2562
2659
|
//#region src/core/createRule/createRule.d.ts
|
|
2563
2660
|
/**
|
|
@@ -2700,7 +2797,7 @@ declare function mergeRegles<TRegles extends Record<string, SuperCompatibleRegle
|
|
|
2700
2797
|
//#endregion
|
|
2701
2798
|
//#region src/core/createScopedUseRegle/useCollectScope.d.ts
|
|
2702
2799
|
type useCollectScopeFn<TNamedScoped extends boolean = false> = TNamedScoped extends true ? <const TValue extends Record<string, Record<string, any>>>(namespace?: MaybeRefOrGetter<string>) => {
|
|
2703
|
-
r$: MergedRegles<{ [K in keyof TValue]: RegleRoot<TValue[K]> }>;
|
|
2800
|
+
r$: MergedRegles<{ [K in keyof TValue]: RegleRoot<TValue[K]> & SuperCompatibleRegleRoot }>;
|
|
2704
2801
|
} : <TValue extends Record<string, unknown>[] = Record<string, unknown>[]>(namespace?: MaybeRefOrGetter<string>) => {
|
|
2705
2802
|
r$: MergedScopedRegles<TValue>;
|
|
2706
2803
|
};
|
|
@@ -2737,13 +2834,13 @@ declare function createScopedUseRegle<TCustomRegle extends useRegleFn<any, any>
|
|
|
2737
2834
|
useScopedRegle: TReturnedRegle;
|
|
2738
2835
|
useCollectScope: useCollectScopeFn<TAsRecord>;
|
|
2739
2836
|
};
|
|
2740
|
-
declare const useCollectScope: <TValue extends Record<string, unknown>[] = Record<string, unknown>[]>(namespace?:
|
|
2837
|
+
declare const useCollectScope: <TValue extends Record<string, unknown>[] = Record<string, unknown>[]>(namespace?: vue1.MaybeRefOrGetter<string>) => {
|
|
2741
2838
|
r$: MergedScopedRegles<TValue>;
|
|
2742
2839
|
}, useScopedRegle: useRegleFn<Partial<AllRulesDeclarations>, never, {
|
|
2743
2840
|
dispose: () => void;
|
|
2744
2841
|
register: () => void;
|
|
2745
2842
|
}, {
|
|
2746
|
-
namespace?:
|
|
2843
|
+
namespace?: vue1.MaybeRefOrGetter<string>;
|
|
2747
2844
|
}>;
|
|
2748
2845
|
//#endregion
|
|
2749
2846
|
//#region src/core/createVariant.d.ts
|
|
@@ -2823,4 +2920,4 @@ declare function defineRules<TRules extends RegleUnknownRulesTree>(rules: TRules
|
|
|
2823
2920
|
*/
|
|
2824
2921
|
declare function refineRules<TRules extends RegleUnknownRulesTree, TRefinement extends ReglePartialRuleTree<InferInput<TRules>> & RegleUnknownRulesTree>(rules: TRules, refinement: (state: Ref<InferInput<TRules>>) => TRefinement): (state: Ref<InferInput<TRules>>) => Merge<TRules, TRefinement>;
|
|
2825
2922
|
//#endregion
|
|
2826
|
-
export { $InternalRegleStatus, AllRulesDeclarations, CommonAlphaOptions, CommonComparisonOptions, CreateScopedUseRegleOptions, DeepMaybeRef, DeepReactiveState, DefaultValidatorsTree, FormRuleDeclaration, HaveAnyRequiredProps, InferInput, InferRegleRoot, InferRegleRule, InferRegleRules, InferRegleShortcuts, InferRegleStatusType, InferSafeOutput, InlineRuleDeclaration, InternalRuleType, JoinDiscriminatedUnions, LocalRegleBehaviourOptions, Maybe, MaybeInput, MaybeOutput, MaybeReadonly, MaybeVariantStatus, MergedRegles, MergedScopedRegles, NarrowVariant, NoInferLegacy, PrimitiveTypes, Regle, RegleBehaviourOptions, RegleCollectionErrors, RegleCollectionRuleDecl, RegleCollectionRuleDefinition, RegleCollectionStatus, RegleCommonStatus, RegleComputedRules, RegleCustomFieldStatus, RegleEnforceCustomRequiredRules, RegleEnforceRequiredRules, RegleErrorTree, RegleExternalCollectionErrors, RegleExternalErrorTree, RegleExternalSchemaErrorTree, RegleFieldIssue, RegleFieldStatus, RegleFormPropertyType, RegleInternalRuleDefs, ReglePartialRuleTree, RegleResult, RegleRoot, RegleRuleCore, RegleRuleDecl, RegleRuleDefinition, RegleRuleDefinitionProcessor, RegleRuleDefinitionWithMetadataProcessor, RegleRuleInit, RegleRuleMetadataConsumer, RegleRuleMetadataDefinition, RegleRuleMetadataExtended, RegleRuleRaw, RegleRuleStatus, RegleRuleTypeReturn, RegleRuleWithParamsDefinition, RegleShortcutDefinition, RegleSingleField, RegleStatus, RegleUniversalParams, RegleUnknownRulesTree, RegleValidationErrors, RegleValidationGroupEntry, RegleValidationGroupOutput, RegleRuleTree as RegleValidationTree, ResolvedRegleBehaviourOptions, ScopedInstancesRecord, ScopedInstancesRecordLike, SuperCompatibleRegle, SuperCompatibleRegleCollectionErrors, SuperCompatibleRegleCollectionStatus, SuperCompatibleRegleFieldStatus, SuperCompatibleRegleResult, SuperCompatibleRegleRoot, SuperCompatibleRegleRuleStatus, SuperCompatibleRegleStatus, Unwrap, UnwrapRegleUniversalParams, UnwrapRuleWithParams, UseScopedRegleOptions, createRule, createScopedUseRegle, createVariant, defineRegleConfig, defineRules, extendRegleConfig, flatErrors, inferRules, inferRulesFn, mergeRegles, narrowVariant, refineRules, unwrapRuleParameters, useCollectScope, useCollectScopeFn, useRegle, useRegleFn, useRootStorage, useScopedRegle, variantToRef };
|
|
2923
|
+
export { $InternalRegleStatus, AllRulesDeclarations, CommonAlphaOptions, CommonComparisonOptions, CreateScopedUseRegleOptions, DeepMaybeRef, DeepReactiveState, DefaultValidatorsTree, FormRuleDeclaration, HasNamedKeys, HaveAnyRequiredProps, InferInput, InferRegleRoot, InferRegleRule, InferRegleRules, InferRegleShortcuts, InferRegleStatusType, InferSafeOutput, InlineRuleDeclaration, InternalRuleType, JoinDiscriminatedUnions, LocalRegleBehaviourOptions, Maybe, MaybeInput, MaybeOutput, MaybeReadonly, MaybeVariantStatus, MergedRegles, MergedScopedRegles, NarrowVariant, NoInferLegacy, PrimitiveTypes, Regle, RegleBehaviourOptions, RegleCollectionErrors, RegleCollectionRuleDecl, RegleCollectionRuleDefinition, RegleCollectionStatus, RegleCommonStatus, RegleComputedRules, RegleCustomFieldStatus, RegleEnforceCustomRequiredRules, RegleEnforceRequiredRules, RegleErrorTree, RegleExternalCollectionErrors, RegleExternalErrorTree, RegleExternalSchemaErrorTree, RegleFieldIssue, RegleFieldStatus, RegleFormPropertyType, RegleInternalRuleDefs, RegleIssuesTree, ReglePartialRuleTree, RegleResult, RegleRoot, RegleRuleCore, RegleRuleDecl, RegleRuleDefinition, RegleRuleDefinitionProcessor, RegleRuleDefinitionWithMetadataProcessor, RegleRuleInit, RegleRuleMetadataConsumer, RegleRuleMetadataDefinition, RegleRuleMetadataExtended, RegleRuleRaw, RegleRuleStatus, RegleRuleTypeReturn, RegleRuleWithParamsDefinition, RegleShortcutDefinition, RegleSingleField, RegleStatus, RegleUniversalParams, RegleUnknownRulesTree, RegleValidationErrors, RegleValidationGroupEntry, RegleValidationGroupOutput, RegleRuleTree as RegleValidationTree, ResolvedRegleBehaviourOptions, ScopedInstancesRecord, ScopedInstancesRecordLike, SuperCompatibleRegle, SuperCompatibleRegleCollectionErrors, SuperCompatibleRegleCollectionStatus, SuperCompatibleRegleFieldStatus, SuperCompatibleRegleResult, SuperCompatibleRegleRoot, SuperCompatibleRegleRuleStatus, SuperCompatibleRegleStatus, Unwrap, UnwrapRegleUniversalParams, UnwrapRuleWithParams, UseScopedRegleOptions, createRule, createScopedUseRegle, createVariant, defineRegleConfig, defineRules, extendRegleConfig, flatErrors, inferRules, inferRulesFn, mergeRegles, narrowVariant, refineRules, unwrapRuleParameters, useCollectScope, useCollectScopeFn, useRegle, useRegleFn, useRootStorage, useScopedRegle, variantToRef };
|