@regle/core 1.19.9 → 1.19.12

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @regle/core v1.19.9
2
+ * @regle/core v1.19.12
3
3
  * (c) 2026 Victor Garcia
4
4
  * @license MIT
5
5
  */
@@ -67,6 +67,11 @@ interface RegleBehaviourOptions {
67
67
  * @default false
68
68
  */
69
69
  immediateDirty?: boolean | undefined;
70
+ /**
71
+ * Disable all the computation
72
+ * @default false
73
+ */
74
+ disabled?: boolean | undefined;
70
75
  }
71
76
  interface LocalRegleBehaviourOptions<TState extends Record<string, any>, TRules extends ReglePartialRuleTree<TState>, TValidationGroups extends Record<string, RegleValidationGroupEntry[]> = {}> {
72
77
  /**
@@ -96,6 +101,17 @@ interface LocalRegleBehaviourOptions<TState extends Record<string, any>, TRules
96
101
  */
97
102
  id?: string | undefined;
98
103
  }
104
+ type FieldOnlyRegleBehaviourOptions = {
105
+ /**
106
+ * Set external errors for the field.
107
+ */
108
+ externalErrors?: Ref<string[]>;
109
+ /**
110
+ * A unique identifier for the Regle instance in the devtools.
111
+ * @default undefined
112
+ */
113
+ id?: string | undefined;
114
+ };
99
115
  type RegleValidationGroupEntry = RegleFieldStatus<any, any> | undefined;
100
116
  interface RegleValidationGroupOutput {
101
117
  /** Indicates whether any field in the validation group is invalid. */
@@ -391,9 +407,10 @@ type UnwrapSimple<T extends MaybeRef<Record<string, any>>> = T extends MaybeComp
391
407
  type ExtractFromGetter<T extends MaybeGetter<any, any, any>> = T extends ((value: Ref<any>, index: number) => infer U extends Record<string, any>) ? U : T;
392
408
  type ExtendOnlyRealRecord<T extends unknown> = NonNullable<T> extends File | Date | RegleStatic<{}> | RegleStaticImpl<{}> ? false : NonNullable<T> extends Record<string, any> ? true : false;
393
409
  type OmitByType<T extends Record<string, any>, U> = { [K in keyof T as T[K] extends U ? never : K]: T[K] };
394
- type DeepMaybeRef<T extends Record<string, any>> = { [K in keyof T]: MaybeRef<T[K]> };
410
+ type DeepMaybeRef<T extends Record<string, any>> = { [K in keyof T]: MaybeRefOrGetter<T[K]> };
395
411
  type ExcludeByType<T, U> = { [K in keyof T as T[K] extends U ? never : K]: T[K] extends U ? never : T[K] };
396
412
  type PrimitiveTypes = string | number | boolean | bigint | Date | File;
413
+ type WidenPrimitiveLiterals<T> = T extends string ? string : T extends number ? number : T extends boolean ? boolean : T extends bigint ? bigint : T;
397
414
  type isRecordLiteral<T extends unknown> = NonNullable<T> extends Date | File | RegleStatic<unknown> | RegleStaticImpl<unknown> ? false : NonNullable<T> extends Record<string, any> ? true : false;
398
415
  type NoInferLegacy<A extends any> = [A][A extends any ? 0 : never];
399
416
  /**
@@ -683,9 +700,9 @@ declare function extendRegleConfig<TRootCustomRules extends Partial<ExtendedRule
683
700
  * @see {@link https://reglejs.dev/advanced-usage/global-config Documentation}
684
701
  */
685
702
  declare function defineRegleOptions<T extends GlobalConfigOptions<Partial<ExtendedRulesDeclarationsOverrides>, RegleShortcutDefinition<any>>>(options: T): T;
686
- type useRegleFnOptions<TState extends Record<string, any> | MaybeInput<PrimitiveTypes>, TRules extends ReglePartialRuleTree<NonNullable<JoinDiscriminatedUnions<TState>>, CustomRulesDeclarationTree>, TAdditionalOptions extends Record<string, any>, TValidationGroups extends Record<string, RegleValidationGroupEntry[]>> = TState extends Record<string, any> ? Partial<DeepMaybeRef<RegleBehaviourOptions>> & LocalRegleBehaviourOptions<JoinDiscriminatedUnions<TState>, TRules, TValidationGroups> & TAdditionalOptions : Partial<DeepMaybeRef<RegleBehaviourOptions>> & TAdditionalOptions;
703
+ type useRegleFnOptions<TState extends Record<string, any> | MaybeInput<PrimitiveTypes>, TRules extends ReglePartialRuleTree<NonNullable<JoinDiscriminatedUnions<TState>>, CustomRulesDeclarationTree>, TAdditionalOptions extends Record<string, any>, TValidationGroups extends Record<string, RegleValidationGroupEntry[]>> = TState extends Record<string, any> ? Partial<DeepMaybeRef<RegleBehaviourOptions>> & LocalRegleBehaviourOptions<JoinDiscriminatedUnions<TState>, TRules, TValidationGroups> & TAdditionalOptions : Partial<DeepMaybeRef<RegleBehaviourOptions & FieldOnlyRegleBehaviourOptions>> & TAdditionalOptions;
687
704
  interface useRegleFn<TCustomRules extends Partial<ExtendedRulesDeclarationsOverrides>, TShortcuts extends RegleShortcutDefinition<any> = never, TAdditionalReturnProperties extends Record<string, any> = {}, TAdditionalOptions extends Record<string, any> = {}> {
688
- <TState extends MaybeRef<Record<string, any> | MaybeInput<PrimitiveTypes>>, TRules extends ReglePartialRuleTree<JoinDiscriminatedUnions<Unwrap<TState>>, Partial<ExtendedRulesDeclarations & Omit<TCustomRules, keyof DefaultValidatorsTree>>>, TDecl extends RegleRuleDecl<NonNullable<Unwrap<TState>>, Partial<ExtendedRulesDeclarations & TCustomRules>>, TValidationGroups extends Record<string, RegleValidationGroupEntry[]>>(...params: [state: Maybe<TState> | DeepReactiveState<TState>, rulesFactory: Unwrap<TState> extends MaybeInput<PrimitiveTypes> ? MaybeRefOrGetter<TDecl> : Unwrap<TState> extends Record<string, any> ? MaybeComputedOrGetter<TRules> : {}, ...(HaveAnyRequiredProps<useRegleFnOptions<Unwrap<TState>, TRules, TAdditionalOptions, TValidationGroups>> extends true ? [options: useRegleFnOptions<Unwrap<NoInferLegacy<TState>>, TRules, TAdditionalOptions, TValidationGroups>] : [options?: useRegleFnOptions<Unwrap<NoInferLegacy<TState>>, TRules, TAdditionalOptions, TValidationGroups>])]): NonNullable<Unwrap<TState>> extends PrimitiveTypes ? RegleSingleField<NonNullable<Unwrap<TState>>, TDecl, TShortcuts, TAdditionalReturnProperties> : Regle<Unwrap<TState> extends Record<string, any> ? Unwrap<TState> : {}, UnwrapSimple<TRules> extends Record<string, any> ? UnwrapSimple<TRules> : {}, TValidationGroups, TShortcuts, TAdditionalReturnProperties>;
705
+ <TState extends MaybeRef<Record<string, any> | MaybeInput<PrimitiveTypes>>, TRules extends ReglePartialRuleTree<JoinDiscriminatedUnions<Unwrap<TState>>, Partial<ExtendedRulesDeclarations & Omit<TCustomRules, keyof DefaultValidatorsTree>>>, TDecl extends RegleRuleDecl<WidenPrimitiveLiterals<NonNullable<Unwrap<TState>>>, Partial<ExtendedRulesDeclarations & TCustomRules>>, TValidationGroups extends Record<string, RegleValidationGroupEntry[]>>(...params: [state: Maybe<TState> | DeepReactiveState<TState>, rulesFactory: Unwrap<TState> extends MaybeInput<PrimitiveTypes> ? MaybeRefOrGetter<TDecl> : Unwrap<TState> extends Record<string, any> ? MaybeComputedOrGetter<TRules> : {}, ...(HaveAnyRequiredProps<useRegleFnOptions<Unwrap<TState>, TRules, TAdditionalOptions, TValidationGroups>> extends true ? [options: useRegleFnOptions<Unwrap<NoInferLegacy<TState>>, TRules, TAdditionalOptions, TValidationGroups>] : [options?: useRegleFnOptions<Unwrap<NoInferLegacy<TState>>, TRules, TAdditionalOptions, TValidationGroups>])]): NonNullable<Unwrap<TState>> extends PrimitiveTypes ? RegleSingleField<WidenPrimitiveLiterals<NonNullable<Unwrap<TState>>>, TDecl, TShortcuts, TAdditionalReturnProperties> : Regle<Unwrap<TState> extends Record<string, any> ? Unwrap<TState> : {}, UnwrapSimple<TRules> extends Record<string, any> ? UnwrapSimple<TRules> : {}, TValidationGroups, TShortcuts, TAdditionalReturnProperties>;
689
706
  __config?: GlobalConfigOptions<TCustomRules, TShortcuts>;
690
707
  }
691
708
  /**
@@ -751,9 +768,7 @@ declare function useRootStorage({
751
768
  schemaMode?: boolean;
752
769
  onValidate?: () => Promise<$InternalRegleResult>;
753
770
  overrides: GlobalConfigOverrides | undefined;
754
- }): {
755
- regle: $InternalRegleStatusType | undefined;
756
- };
771
+ }): Ref<$InternalRegleStatusType | undefined, $InternalRegleStatusType | undefined>;
757
772
  /**
758
773
  * Converts a nested `$errors` object to a flat array of error strings.
759
774
  * Useful for displaying a complete list of form errors or counting total errors.
@@ -828,7 +843,7 @@ declare function flatErrors(errors: $InternalRegleErrors, options?: {
828
843
  *
829
844
  * @see {@link https://reglejs.dev/core-concepts/displaying-errors#get-errors-by-path Documentation}
830
845
  */
831
- declare function getErrors<TRegle extends SuperCompatibleRegleRoot | SuperCompatibleRegleStatus, TPath extends Paths<TRegle['$errors']> | (string & {})>(r$: MaybeRef<TRegle>, path: TPath): IsStringLiteral<TPath> extends true ? Get<TRegle['$errors'], TPath & string> : string[] | undefined;
846
+ declare function getErrors<TRegle extends SuperCompatibleRegleRoot | SuperCompatibleRegleStatus, TPath extends Paths<TRegle['$errors']> | (string & {})>(r$: MaybeRefOrGetter<TRegle>, path: TPath): IsStringLiteral<TPath> extends true ? Get<TRegle['$errors'], TPath & string> : string[] | undefined;
832
847
  /**
833
848
  * Retrieves detailed validation issues for a specific field using a dot-notation path.
834
849
  * Issues contain more information than errors, including the rule name, property, and metadata.
@@ -866,7 +881,7 @@ declare function getErrors<TRegle extends SuperCompatibleRegleRoot | SuperCompat
866
881
  *
867
882
  * @see {@link https://reglejs.dev/core-concepts/displaying-errors#get-issues-by-path Documentation}
868
883
  */
869
- declare function getIssues<TRegle extends SuperCompatibleRegleRoot | SuperCompatibleRegleStatus, TPath extends Paths<TRegle['$issues']>>(r$: MaybeRef<TRegle>, path: TPath | (string & {})): IsStringLiteral<TPath> extends true ? Get<TRegle['$issues'], TPath & string> : RegleFieldIssue[] | undefined;
884
+ declare function getIssues<TRegle extends SuperCompatibleRegleRoot | SuperCompatibleRegleStatus, TPath extends Paths<TRegle['$issues']>>(r$: MaybeRefOrGetter<TRegle>, path: TPath | (string & {})): IsStringLiteral<TPath> extends true ? Get<TRegle['$issues'], TPath & string> : RegleFieldIssue[] | undefined;
870
885
  type useRulesFnOptions<TRules extends RegleUnknownRulesTree | RegleRuleDecl, TValidationGroups extends Record<string, RegleValidationGroupEntry[]>, TState = InferInput<TRules>> = Partial<DeepMaybeRef<RegleBehaviourOptions>> & LocalRegleBehaviourOptions<JoinDiscriminatedUnions<TState extends Record<string, any> ? Unwrap<TState> : {}>, TState extends Record<string, any> ? (TRules extends Record<string, any> ? TRules : {}) : {}, TValidationGroups>;
871
886
  interface useRulesFn<TCustomRules extends Partial<ExtendedRulesDeclarationsOverrides>, TShortcuts extends RegleShortcutDefinition<any> = never> {
872
887
  <TRules extends RegleUnknownRulesTree | RegleRuleDecl, TDecl extends RegleRuleDecl<NonNullable<TState>, Partial<ExtendedRulesDeclarations> & TCustomRules>, TValidationGroups extends Record<string, RegleValidationGroupEntry[]>, TState extends Record<string, any> = InferInput<TRules>>(rulesFactory: TState extends Record<string, any> ? MaybeRef<TRules> | ((...args: any[]) => TRules) : {}, options?: useRulesFnOptions<TRules, TValidationGroups, TState>): NonNullable<TState> extends PrimitiveTypes ? Raw<RegleFieldStatus<NonNullable<TState>, TDecl, TShortcuts>> & StandardSchemaV1<TState> : Raw<RegleRoot<TState extends Record<string, any> ? Unwrap<TState> : {}, TRules extends Record<string, any> ? TRules : {}, TValidationGroups, TShortcuts>> & StandardSchemaV1<TState>;
@@ -2208,4 +2223,4 @@ declare function isRegleInstance(value: unknown): boolean;
2208
2223
  * @see {@link https://reglejs.dev/introduction/devtools Documentation}
2209
2224
  */
2210
2225
  declare const RegleVuePlugin: Plugin;
2211
- export { type $InternalRegleStatus, type AllRulesDeclarations, type ArrayElement, type CommonAlphaOptions, type CommonComparisonOptions, type CreateScopedUseRegleOptions, type CustomCollectionProperties, type CustomFieldProperties, type CustomNestedProperties, type CustomRules, type DeepMaybeRef, type DeepPartial, type DeepReactiveState, type DefaultValidatorsTree, type DumbJoinDiscriminatedUnions, type ExtendedRulesDeclarations, type FormRuleDeclaration, type GlobalConfigOverrides, type HasNamedKeys, type HaveAnyRequiredProps, type InferInput, type InferOutput, type InferRegleRoot, type InferRegleRule, type InferRegleRules, type InferRegleSettings, type InferRegleShortcuts, type InferRegleStatusType, type InferRegleValidationResult, type InferSafeOutput, type InferValidOutput, type InlineRuleDeclaration, InternalRuleType, type IsRegleStatic, type JoinDiscriminatedUnions, type LazyJoinDiscriminatedUnions, type LocalRegleBehaviourOptions, type Maybe, type MaybeInput, type MaybeOutput, type MaybeReadonly, type MaybeVariantStatus, type MergedRegles, type MergedScopedRegles, type NarrowVariant, type NarrowVariantExtracts, type NarrowVariantFieldExtracts, type NoInferLegacy, type NonEmptyTuple, type ParamsToLooseParams, type Prettify, type PrimitiveTypes, type Regle, type RegleBehaviourOptions, type RegleCollectionErrors, type RegleCollectionRuleDecl, type RegleCollectionRuleDefinition, type RegleCollectionStatus, type RegleCommonStatus, type RegleComputedRules, type RegleCustomFieldStatus, type RegleEnforceCustomRequiredRules, type RegleEnforceRequiredRules, type RegleErrorTree, type RegleExternalCollectionErrors, type RegleExternalErrorTree, type RegleExternalSchemaErrorTree, type RegleFieldIssue, type RegleFieldStatus, type RegleFormPropertyType, type RegleInternalRuleDefs, type RegleIssuesTree, type RegleLike, type ReglePartialRuleTree, type RegleResult, type RegleRoot, type RegleRuleCore, type RegleRuleDecl, type RegleRuleDefinition, type RegleRuleDefinitionProcessor, type RegleRuleDefinitionWithMetadataProcessor, type RegleRuleInit, type RegleRuleMetadataConsumer, type RegleRuleMetadataDefinition, type RegleRuleMetadataExtended, type RegleRuleRaw, type RegleRuleStatus, type RegleRuleTypeReturn, type RegleRuleWithParamsDefinition, type RegleRuleWithParamsDefinitionInput, type RegleShortcutDefinition, type RegleSingleField, type RegleStatic, type RegleStaticImpl, type RegleStatus, type RegleUniversalParams, type RegleUnknownRulesTree, type RegleValidationErrors, type RegleValidationGroupEntry, type RegleValidationGroupOutput, type RegleRuleTree as RegleValidationTree, RegleVuePlugin, type ResolvedRegleBehaviourOptions, type ScopedInstancesRecord, type ScopedInstancesRecordLike, type SuperCompatibleRegle, type SuperCompatibleRegleCollectionErrors, type SuperCompatibleRegleCollectionStatus, type SuperCompatibleRegleFieldStatus, type SuperCompatibleRegleResult, type SuperCompatibleRegleRoot, type SuperCompatibleRegleRuleStatus, type SuperCompatibleRegleStatus, type TupleToPlainObj, type Unwrap, type UnwrapRegleUniversalParams, type UnwrapRuleWithParams, type UnwrapStatic, type UrlOptions, type UseScopedRegleOptions, createRule, createScopedUseRegle, createVariant, defineRegleConfig, defineRegleOptions, defineRules, extendRegleConfig, flatErrors, getErrors, getIssues, inferRules, type inferRulesFn, type isEditedHandlerFn, isRegleInstance, markStatic, mergeRegles, narrowVariant, refineRules, unwrapRuleParameters, useCollectScope, type useCollectScopeFn, useRegle, type useRegleFn, useRootStorage, useRules, type useRulesFn, useScopedRegle, variantToRef };
2226
+ export { type $InternalRegleStatus, type AllRulesDeclarations, type ArrayElement, type CommonAlphaOptions, type CommonComparisonOptions, type CreateScopedUseRegleOptions, type CustomCollectionProperties, type CustomFieldProperties, type CustomNestedProperties, type CustomRules, type DeepMaybeRef, type DeepPartial, type DeepReactiveState, type DefaultValidatorsTree, type DumbJoinDiscriminatedUnions, type ExtendedRulesDeclarations, type ExtendedRulesDeclarationsOverrides, type FormRuleDeclaration, type GlobalConfigOverrides, type HasNamedKeys, type HaveAnyRequiredProps, type InferInput, type InferOutput, type InferRegleRoot, type InferRegleRule, type InferRegleRules, type InferRegleSettings, type InferRegleShortcuts, type InferRegleStatusType, type InferRegleValidationResult, type InferSafeOutput, type InferValidOutput, type InlineRuleDeclaration, InternalRuleType, type IsRegleStatic, type JoinDiscriminatedUnions, type LazyJoinDiscriminatedUnions, type LocalRegleBehaviourOptions, type Maybe, type MaybeInput, type MaybeOutput, type MaybeReadonly, type MaybeVariantStatus, type MergedRegles, type MergedScopedRegles, type NarrowVariant, type NarrowVariantExtracts, type NarrowVariantFieldExtracts, type NoInferLegacy, type NonEmptyTuple, type ParamsToLooseParams, type Prettify, type PrimitiveTypes, type Regle, type RegleBehaviourOptions, type RegleCollectionErrors, type RegleCollectionRuleDecl, type RegleCollectionRuleDefinition, type RegleCollectionStatus, type RegleCommonStatus, type RegleComputedRules, type RegleCustomFieldStatus, type RegleEnforceCustomRequiredRules, type RegleEnforceRequiredRules, type RegleErrorTree, type RegleExternalCollectionErrors, type RegleExternalErrorTree, type RegleExternalSchemaErrorTree, type RegleFieldIssue, type RegleFieldStatus, type RegleFormPropertyType, type RegleInternalRuleDefs, type RegleIssuesTree, type RegleLike, type ReglePartialRuleTree, type RegleResult, type RegleRoot, type RegleRuleCore, type RegleRuleDecl, type RegleRuleDefinition, type RegleRuleDefinitionProcessor, type RegleRuleDefinitionWithMetadataProcessor, type RegleRuleInit, type RegleRuleMetadataConsumer, type RegleRuleMetadataDefinition, type RegleRuleMetadataExtended, type RegleRuleRaw, type RegleRuleStatus, type RegleRuleTypeReturn, type RegleRuleWithParamsDefinition, type RegleRuleWithParamsDefinitionInput, type RegleShortcutDefinition, type RegleSingleField, type RegleStatic, type RegleStaticImpl, type RegleStatus, type RegleUniversalParams, type RegleUnknownRulesTree, type RegleValidationErrors, type RegleValidationGroupEntry, type RegleValidationGroupOutput, type RegleRuleTree as RegleValidationTree, RegleVuePlugin, type ResolvedRegleBehaviourOptions, type ScopedInstancesRecord, type ScopedInstancesRecordLike, type SuperCompatibleRegle, type SuperCompatibleRegleCollectionErrors, type SuperCompatibleRegleCollectionStatus, type SuperCompatibleRegleFieldStatus, type SuperCompatibleRegleResult, type SuperCompatibleRegleRoot, type SuperCompatibleRegleRuleStatus, type SuperCompatibleRegleStatus, type TupleToPlainObj, type Unwrap, type UnwrapRegleUniversalParams, type UnwrapRuleWithParams, type UnwrapStatic, type UrlOptions, type UseScopedRegleOptions, createRule, createScopedUseRegle, createVariant, defineRegleConfig, defineRegleOptions, defineRules, extendRegleConfig, flatErrors, getErrors, getIssues, inferRules, type inferRulesFn, type isEditedHandlerFn, isRegleInstance, markStatic, mergeRegles, narrowVariant, refineRules, unwrapRuleParameters, useCollectScope, type useCollectScopeFn, useRegle, type useRegleFn, useRootStorage, useRules, type useRulesFn, useScopedRegle, variantToRef };