@regle/core 0.1.6 → 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.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, any>;
77
+ type RegleValidationGroupEntry = RegleFieldStatus<any, any>;
78
78
  interface RegleValidationGroupOutput {
79
79
  $invalid: boolean;
80
80
  $error: boolean;
@@ -93,6 +93,7 @@ type AddDollarToOptions<T extends Record<string, any>> = {
93
93
 
94
94
  interface Regle<TState extends Record<string, any> = EmptyObject, TRules extends ReglePartialValidationTree<TState, CustomRulesDeclarationTree> = EmptyObject, TExternal extends RegleExternalErrorTree<TState> = never, TValidationGroups extends Record<string, RegleValidationGroupEntry[]> = never> {
95
95
  regle: RegleStatus<TState, TRules, TValidationGroups>;
96
+ r$: RegleStatus<TState, TRules, TValidationGroups>;
96
97
  /** Show active errors based on your behaviour options (lazy, autoDirty)
97
98
  * It allow you to skip scouting the `regle` object
98
99
  */
@@ -376,17 +377,17 @@ type RegleStatus<TState extends Record<string, any> = Record<string, any>, TRule
376
377
  /**
377
378
  * @public
378
379
  */
379
- 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']>, TState[TKey], TRule> : never : RegleFieldStatus<TRule, TState, TKey> : 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<TRule, TState, TKey> : RegleFieldStatus<TRule, TState, TKey>;
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>;
380
381
  /**
381
382
  * @public
382
383
  */
383
- interface RegleFieldStatus<TRules extends RegleFormPropertyType<any, Partial<AllRulesDeclarations>> = Record<string, any>, TState extends Record<PropertyKey, any> = any, TKey extends PropertyKey = string> extends RegleCommonStatus<TState> {
384
- $value: UnwrapNestedRefs<TState[TKey]>;
384
+ interface RegleFieldStatus<TState extends any = unknown, TRules extends RegleFormPropertyType<any, Partial<AllRulesDeclarations>> = Record<string, any>> extends RegleCommonStatus<TState> {
385
+ $value: UnwrapNestedRefs<TState>;
385
386
  readonly $errors: string[];
386
387
  readonly $silentErrors: string[];
387
388
  readonly $externalErrors?: string[];
388
389
  readonly $rules: {
389
- readonly [TRuleKey in keyof Omit<TRules, '$each' | keyof FieldRegleBehaviourOptions>]: RegleRuleStatus<TState[TKey], 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>;
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>;
390
391
  };
391
392
  }
392
393
  /**
@@ -428,9 +429,9 @@ type RegleRuleStatus<TValue = any, TParams extends any[] = any[], TMetadata exte
428
429
  /**
429
430
  * @public
430
431
  */
431
- interface RegleCollectionStatus<TRules extends RegleRuleDecl | ReglePartialValidationTree<any>, TState extends any[], TFieldRule extends RegleCollectionRuleDecl<any, any> = never> extends Omit<RegleFieldStatus<TRules, TState>, '$errors' | '$silentErrors'> {
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'> {
432
433
  readonly $each: Array<InferRegleStatusType<NonNullable<TRules>, NonNullable<TState>, number>>;
433
- readonly $field: RegleFieldStatus<TFieldRule, TState>;
434
+ readonly $field: RegleFieldStatus<TState, TFieldRule>;
434
435
  readonly $errors: RegleErrorTree<TRules>;
435
436
  readonly $silentErrors: RegleErrorTree<TRules>;
436
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, any>;
77
+ type RegleValidationGroupEntry = RegleFieldStatus<any, any>;
78
78
  interface RegleValidationGroupOutput {
79
79
  $invalid: boolean;
80
80
  $error: boolean;
@@ -93,6 +93,7 @@ type AddDollarToOptions<T extends Record<string, any>> = {
93
93
 
94
94
  interface Regle<TState extends Record<string, any> = EmptyObject, TRules extends ReglePartialValidationTree<TState, CustomRulesDeclarationTree> = EmptyObject, TExternal extends RegleExternalErrorTree<TState> = never, TValidationGroups extends Record<string, RegleValidationGroupEntry[]> = never> {
95
95
  regle: RegleStatus<TState, TRules, TValidationGroups>;
96
+ r$: RegleStatus<TState, TRules, TValidationGroups>;
96
97
  /** Show active errors based on your behaviour options (lazy, autoDirty)
97
98
  * It allow you to skip scouting the `regle` object
98
99
  */
@@ -376,17 +377,17 @@ type RegleStatus<TState extends Record<string, any> = Record<string, any>, TRule
376
377
  /**
377
378
  * @public
378
379
  */
379
- 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']>, TState[TKey], TRule> : never : RegleFieldStatus<TRule, TState, TKey> : 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<TRule, TState, TKey> : RegleFieldStatus<TRule, TState, TKey>;
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>;
380
381
  /**
381
382
  * @public
382
383
  */
383
- interface RegleFieldStatus<TRules extends RegleFormPropertyType<any, Partial<AllRulesDeclarations>> = Record<string, any>, TState extends Record<PropertyKey, any> = any, TKey extends PropertyKey = string> extends RegleCommonStatus<TState> {
384
- $value: UnwrapNestedRefs<TState[TKey]>;
384
+ interface RegleFieldStatus<TState extends any = unknown, TRules extends RegleFormPropertyType<any, Partial<AllRulesDeclarations>> = Record<string, any>> extends RegleCommonStatus<TState> {
385
+ $value: UnwrapNestedRefs<TState>;
385
386
  readonly $errors: string[];
386
387
  readonly $silentErrors: string[];
387
388
  readonly $externalErrors?: string[];
388
389
  readonly $rules: {
389
- readonly [TRuleKey in keyof Omit<TRules, '$each' | keyof FieldRegleBehaviourOptions>]: RegleRuleStatus<TState[TKey], 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>;
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>;
390
391
  };
391
392
  }
392
393
  /**
@@ -428,9 +429,9 @@ type RegleRuleStatus<TValue = any, TParams extends any[] = any[], TMetadata exte
428
429
  /**
429
430
  * @public
430
431
  */
431
- interface RegleCollectionStatus<TRules extends RegleRuleDecl | ReglePartialValidationTree<any>, TState extends any[], TFieldRule extends RegleCollectionRuleDecl<any, any> = never> extends Omit<RegleFieldStatus<TRules, TState>, '$errors' | '$silentErrors'> {
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'> {
432
433
  readonly $each: Array<InferRegleStatusType<NonNullable<TRules>, NonNullable<TState>, number>>;
433
- readonly $field: RegleFieldStatus<TFieldRule, TState>;
434
+ readonly $field: RegleFieldStatus<TState, TFieldRule>;
434
435
  readonly $errors: RegleErrorTree<TRules>;
435
436
  readonly $silentErrors: RegleErrorTree<TRules>;
436
437
  }