@regle/core 0.5.4 β†’ 0.5.6

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 CHANGED
@@ -23,8 +23,8 @@ It's heavily inspired by Vuelidate.
23
23
  - βœ… Typescript first
24
24
  - πŸ€– 100% type inference
25
25
  - πŸ“– Model based validation
26
+ - πŸ›’ Collection validation
26
27
  - πŸͺ— Extensible
27
28
  - πŸ¦Έβ€β™‚οΈ [Zod](https://zod.dev/) support
28
29
  - πŸ€– [Valibot](https://valibot.dev/) support
29
- - πŸͺΆ Light(~7kb gzip) and 0 dependencies
30
- - πŸ›’ Collection validation
30
+ - πŸͺΆ Light(~7kb gzip) and 0 dependencies
@@ -897,7 +897,6 @@ type MismatchInfo<Actual, Expected> = And<[Extends<PrintType<Actual>, '...'>, No
897
897
  [K in UsefulKeys<Actual> | UsefulKeys<Expected>]: MismatchInfo<K extends keyof Actual ? Actual[K] : never, K extends keyof Expected ? Expected[K] : never>;
898
898
  } : StrictEqualUsingBranding<Actual, Expected> extends true ? Actual : `[Regle error] The parent property does not match the form schema`;
899
899
 
900
- type ParamDecl<T = any> = MaybeRef<Maybe<T>> | (() => Maybe<T>);
901
900
  type CreateFn<T extends any[]> = (...args: T) => any;
902
901
  /**
903
902
  * Transform normal parameters tuple declaration to a rich tuple declaration
@@ -905,10 +904,10 @@ type CreateFn<T extends any[]> = (...args: T) => any;
905
904
  * [foo: string, bar?: number] => [foo: MaybeRef<string> | (() => string), bar?: MaybeRef<number | undefined> | (() => number) | undefined]
906
905
  */
907
906
  type RegleUniversalParams<T extends any[] = [], F = CreateFn<T>> = [T] extends [[]] ? [] : Parameters<F extends (...args: infer Args) => any ? (...args: {
908
- [K in keyof Args]: ParamDecl<Args[K]>;
907
+ [K in keyof Args]: MaybeRefOrGetter<Maybe<Args[K]>>;
909
908
  }) => any : never>;
910
- type UnwrapRegleUniversalParams<T extends ParamDecl[] = [], F = CreateFn<T>> = [T] extends [[]] ? [] : Parameters<F extends (...args: infer Args) => any ? (...args: {
911
- [K in keyof Args]: Args[K] extends ParamDecl<infer U> ? U : Args[K];
909
+ type UnwrapRegleUniversalParams<T extends MaybeRefOrGetter[] = [], F = CreateFn<T>> = [T] extends [[]] ? [] : Parameters<F extends (...args: infer Args) => any ? (...args: {
910
+ [K in keyof Args]: Args[K] extends MaybeRefOrGetter<Maybe<infer U>> ? U : Args[K];
912
911
  }) => any : never>;
913
912
 
914
913
  /**
@@ -1382,7 +1381,6 @@ interface $InternalRegleCollectionStatus extends Omit<$InternalRegleStatus, '$fi
1382
1381
  }
1383
1382
 
1384
1383
  /**
1385
- * @description
1386
1384
  * Create a typed custom rule that can be used like default rules.
1387
1385
  * It can also be declared in the global options
1388
1386
  *
@@ -1402,7 +1400,7 @@ interface $InternalRegleCollectionStatus extends Omit<$InternalRegleStatus, '$fi
1402
1400
  * import {isFilled} from '@regle/rules';
1403
1401
  *
1404
1402
  * export const isFoo = createRule({
1405
- * validator(value: string) {
1403
+ * validator(value: Maybe<string>) {
1406
1404
  * if (isFilled(value)) {
1407
1405
  * return value === 'foo';
1408
1406
  * }
@@ -1418,7 +1416,7 @@ declare function createRule<TValue extends any, TParams extends any[], TReturn e
1418
1416
  * Returns a clean list of parameters
1419
1417
  * Removing Ref and executing function to return the unwraped value
1420
1418
  */
1421
- declare function unwrapRuleParameters<TParams extends any[]>(params: ParamDecl[]): TParams;
1419
+ declare function unwrapRuleParameters<TParams extends any[]>(params: MaybeRefOrGetter[]): TParams;
1422
1420
 
1423
1421
  declare function defineRegleConfig<TShortcuts extends RegleShortcutDefinition<TCustomRules>, TCustomRules extends Partial<AllRulesDeclarations> = EmptyObject>({ rules, modifiers, shortcuts, }: {
1424
1422
  rules?: () => TCustomRules;
@@ -1429,4 +1427,4 @@ declare function defineRegleConfig<TShortcuts extends RegleShortcutDefinition<TC
1429
1427
  inferRules: inferRulesFn<TCustomRules>;
1430
1428
  };
1431
1429
 
1432
- export { type $InternalRegleStatus, type AllRulesDeclarations, type DeepMaybeRef, type FormRuleDeclaration, type InferRegleRoot, type InferRegleRule, type InferRegleRules, type InferRegleShortcuts, type InferRegleStatusType, type InlineRuleDeclaration, InternalRuleType, type LocalRegleBehaviourOptions, type Maybe, type NoInferLegacy, type ParamDecl, type PrimitiveTypes, type Regle, type RegleBehaviourOptions, type RegleCollectionErrors, type RegleCollectionRuleDecl, type RegleCollectionRuleDefinition, type RegleCollectionStatus, type RegleCommonStatus, type RegleComputedRules, type RegleEnforceCustomRequiredRules, type RegleEnforceRequiredRules, type RegleErrorTree, type RegleExternalCollectionErrors, type RegleExternalErrorTree, type RegleFieldStatus, type RegleFormPropertyType, type RegleInternalRuleDefs, 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 RegleShortcutDefinition, type RegleStatus, type RegleUniversalParams, type RegleValidationErrors, type RegleValidationGroupEntry, type RegleValidationGroupOutput, type RegleRuleTree as RegleValidationTree, type ResolvedRegleBehaviourOptions, type Unwrap, type UnwrapRegleUniversalParams, type UnwrapRuleWithParams, createRule, defineRegleConfig, inferRules, unwrapRuleParameters, useRegle, useRootStorage };
1430
+ export { type $InternalRegleStatus, type AllRulesDeclarations, type DeepMaybeRef, type FormRuleDeclaration, type InferRegleRoot, type InferRegleRule, type InferRegleRules, type InferRegleShortcuts, type InferRegleStatusType, type InlineRuleDeclaration, InternalRuleType, type LocalRegleBehaviourOptions, type Maybe, type NoInferLegacy, type PrimitiveTypes, type Regle, type RegleBehaviourOptions, type RegleCollectionErrors, type RegleCollectionRuleDecl, type RegleCollectionRuleDefinition, type RegleCollectionStatus, type RegleCommonStatus, type RegleComputedRules, type RegleEnforceCustomRequiredRules, type RegleEnforceRequiredRules, type RegleErrorTree, type RegleExternalCollectionErrors, type RegleExternalErrorTree, type RegleFieldStatus, type RegleFormPropertyType, type RegleInternalRuleDefs, 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 RegleShortcutDefinition, type RegleStatus, type RegleUniversalParams, type RegleValidationErrors, type RegleValidationGroupEntry, type RegleValidationGroupOutput, type RegleRuleTree as RegleValidationTree, type ResolvedRegleBehaviourOptions, type Unwrap, type UnwrapRegleUniversalParams, type UnwrapRuleWithParams, createRule, defineRegleConfig, inferRules, unwrapRuleParameters, useRegle, useRootStorage };
@@ -897,7 +897,6 @@ type MismatchInfo<Actual, Expected> = And<[Extends<PrintType<Actual>, '...'>, No
897
897
  [K in UsefulKeys<Actual> | UsefulKeys<Expected>]: MismatchInfo<K extends keyof Actual ? Actual[K] : never, K extends keyof Expected ? Expected[K] : never>;
898
898
  } : StrictEqualUsingBranding<Actual, Expected> extends true ? Actual : `[Regle error] The parent property does not match the form schema`;
899
899
 
900
- type ParamDecl<T = any> = MaybeRef<Maybe<T>> | (() => Maybe<T>);
901
900
  type CreateFn<T extends any[]> = (...args: T) => any;
902
901
  /**
903
902
  * Transform normal parameters tuple declaration to a rich tuple declaration
@@ -905,10 +904,10 @@ type CreateFn<T extends any[]> = (...args: T) => any;
905
904
  * [foo: string, bar?: number] => [foo: MaybeRef<string> | (() => string), bar?: MaybeRef<number | undefined> | (() => number) | undefined]
906
905
  */
907
906
  type RegleUniversalParams<T extends any[] = [], F = CreateFn<T>> = [T] extends [[]] ? [] : Parameters<F extends (...args: infer Args) => any ? (...args: {
908
- [K in keyof Args]: ParamDecl<Args[K]>;
907
+ [K in keyof Args]: MaybeRefOrGetter<Maybe<Args[K]>>;
909
908
  }) => any : never>;
910
- type UnwrapRegleUniversalParams<T extends ParamDecl[] = [], F = CreateFn<T>> = [T] extends [[]] ? [] : Parameters<F extends (...args: infer Args) => any ? (...args: {
911
- [K in keyof Args]: Args[K] extends ParamDecl<infer U> ? U : Args[K];
909
+ type UnwrapRegleUniversalParams<T extends MaybeRefOrGetter[] = [], F = CreateFn<T>> = [T] extends [[]] ? [] : Parameters<F extends (...args: infer Args) => any ? (...args: {
910
+ [K in keyof Args]: Args[K] extends MaybeRefOrGetter<Maybe<infer U>> ? U : Args[K];
912
911
  }) => any : never>;
913
912
 
914
913
  /**
@@ -1382,7 +1381,6 @@ interface $InternalRegleCollectionStatus extends Omit<$InternalRegleStatus, '$fi
1382
1381
  }
1383
1382
 
1384
1383
  /**
1385
- * @description
1386
1384
  * Create a typed custom rule that can be used like default rules.
1387
1385
  * It can also be declared in the global options
1388
1386
  *
@@ -1402,7 +1400,7 @@ interface $InternalRegleCollectionStatus extends Omit<$InternalRegleStatus, '$fi
1402
1400
  * import {isFilled} from '@regle/rules';
1403
1401
  *
1404
1402
  * export const isFoo = createRule({
1405
- * validator(value: string) {
1403
+ * validator(value: Maybe<string>) {
1406
1404
  * if (isFilled(value)) {
1407
1405
  * return value === 'foo';
1408
1406
  * }
@@ -1418,7 +1416,7 @@ declare function createRule<TValue extends any, TParams extends any[], TReturn e
1418
1416
  * Returns a clean list of parameters
1419
1417
  * Removing Ref and executing function to return the unwraped value
1420
1418
  */
1421
- declare function unwrapRuleParameters<TParams extends any[]>(params: ParamDecl[]): TParams;
1419
+ declare function unwrapRuleParameters<TParams extends any[]>(params: MaybeRefOrGetter[]): TParams;
1422
1420
 
1423
1421
  declare function defineRegleConfig<TShortcuts extends RegleShortcutDefinition<TCustomRules>, TCustomRules extends Partial<AllRulesDeclarations> = EmptyObject>({ rules, modifiers, shortcuts, }: {
1424
1422
  rules?: () => TCustomRules;
@@ -1429,4 +1427,4 @@ declare function defineRegleConfig<TShortcuts extends RegleShortcutDefinition<TC
1429
1427
  inferRules: inferRulesFn<TCustomRules>;
1430
1428
  };
1431
1429
 
1432
- export { type $InternalRegleStatus, type AllRulesDeclarations, type DeepMaybeRef, type FormRuleDeclaration, type InferRegleRoot, type InferRegleRule, type InferRegleRules, type InferRegleShortcuts, type InferRegleStatusType, type InlineRuleDeclaration, InternalRuleType, type LocalRegleBehaviourOptions, type Maybe, type NoInferLegacy, type ParamDecl, type PrimitiveTypes, type Regle, type RegleBehaviourOptions, type RegleCollectionErrors, type RegleCollectionRuleDecl, type RegleCollectionRuleDefinition, type RegleCollectionStatus, type RegleCommonStatus, type RegleComputedRules, type RegleEnforceCustomRequiredRules, type RegleEnforceRequiredRules, type RegleErrorTree, type RegleExternalCollectionErrors, type RegleExternalErrorTree, type RegleFieldStatus, type RegleFormPropertyType, type RegleInternalRuleDefs, 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 RegleShortcutDefinition, type RegleStatus, type RegleUniversalParams, type RegleValidationErrors, type RegleValidationGroupEntry, type RegleValidationGroupOutput, type RegleRuleTree as RegleValidationTree, type ResolvedRegleBehaviourOptions, type Unwrap, type UnwrapRegleUniversalParams, type UnwrapRuleWithParams, createRule, defineRegleConfig, inferRules, unwrapRuleParameters, useRegle, useRootStorage };
1430
+ export { type $InternalRegleStatus, type AllRulesDeclarations, type DeepMaybeRef, type FormRuleDeclaration, type InferRegleRoot, type InferRegleRule, type InferRegleRules, type InferRegleShortcuts, type InferRegleStatusType, type InlineRuleDeclaration, InternalRuleType, type LocalRegleBehaviourOptions, type Maybe, type NoInferLegacy, type PrimitiveTypes, type Regle, type RegleBehaviourOptions, type RegleCollectionErrors, type RegleCollectionRuleDecl, type RegleCollectionRuleDefinition, type RegleCollectionStatus, type RegleCommonStatus, type RegleComputedRules, type RegleEnforceCustomRequiredRules, type RegleEnforceRequiredRules, type RegleErrorTree, type RegleExternalCollectionErrors, type RegleExternalErrorTree, type RegleFieldStatus, type RegleFormPropertyType, type RegleInternalRuleDefs, 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 RegleShortcutDefinition, type RegleStatus, type RegleUniversalParams, type RegleValidationErrors, type RegleValidationGroupEntry, type RegleValidationGroupOutput, type RegleRuleTree as RegleValidationTree, type ResolvedRegleBehaviourOptions, type Unwrap, type UnwrapRegleUniversalParams, type UnwrapRuleWithParams, createRule, defineRegleConfig, inferRules, unwrapRuleParameters, useRegle, useRootStorage };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@regle/core",
3
- "version": "0.5.4",
3
+ "version": "0.5.6",
4
4
  "description": "Typescript-first model-based form validation library for Vue 3",
5
5
  "peerDependencies": {
6
6
  "vue": "^3.3.0"