@regle/schemas 1.2.0-beta.1 → 1.2.0-beta.3
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 +17 -11
- package/dist/regle-schemas.d.ts +81 -72
- package/dist/regle-schemas.min.mjs +1 -1
- package/dist/regle-schemas.mjs +1 -0
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -5,24 +5,30 @@
|
|
|
5
5
|
# Regle
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
Regle \ʁɛɡl\ (French word for 'rule'
|
|
8
|
+
Regle \ʁɛɡl\ (French word for 'rule') is a Typescript-first model-based validation library for Vue 3.
|
|
9
9
|
It's heavily inspired by Vuelidate.
|
|
10
10
|
|
|
11
|
+
|
|
11
12
|
## 📚 Documentation
|
|
12
13
|
|
|
13
14
|
[](https://reglejs.dev/)
|
|
14
15
|
|
|
15
16
|
## 🎮 Play with it
|
|
16
17
|
|
|
17
|
-
| Simple demo | Advanced Demo |
|
|
18
|
-
| ------------- | ------------- |
|
|
19
|
-
| [](https://stackblitz.com/~/github.com/victorgarciaesgi/regle-examples/tree/main/examples/simple-example?file=examples/simple-example/src/App.vue&configPath=examples/simple-example) |
|
|
18
|
+
| Playground | Simple demo | Advanced Demo |
|
|
19
|
+
| ------------- | ------------- | ------------- |
|
|
20
|
+
| <a target='_blank' href="https://play.reglejs.dev"><img width="180" src="https://raw.githubusercontent.com/victorgarciaesgi/regle/refs/heads/main/.github/images/regle-playground-button.svg" /></a> | [](https://stackblitz.com/~/github.com/victorgarciaesgi/regle-examples/tree/main/examples/simple-example?file=examples/simple-example/src/App.vue&configPath=examples/simple-example) | [](https://stackblitz.com/~/github.com/victorgarciaesgi/regle-examples/tree/main/examples/advanced-example?file=examples/advanced-example/src/App.vue&configPath=examples/advanced-example) |
|
|
20
21
|
|
|
21
22
|
## 🧰 Features
|
|
22
|
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
-
|
|
23
|
+
|
|
24
|
+
- ☁️ Headless
|
|
25
|
+
- ✅ Type safety
|
|
26
|
+
- 🧮 Model based
|
|
27
|
+
- 🧰 Modular
|
|
28
|
+
- 🔄 Async validation
|
|
29
|
+
- 🌐 Plug any i18n library
|
|
30
|
+
- 📗 Vuelidate compatible API
|
|
31
|
+
- Standard Schemas spec support
|
|
32
|
+
- 🦸♂️ [Zod](https://zod.dev/)
|
|
33
|
+
- 🤖 [Valibot](https://valibot.dev/)
|
|
34
|
+
- 🚢 [ArkType](https://arktype.io) 🚧
|
package/dist/regle-schemas.d.ts
CHANGED
|
@@ -53,6 +53,46 @@ Unfortunately, `Record<string, never>`, `Record<keyof any, never>` and `Record<n
|
|
|
53
53
|
*/
|
|
54
54
|
type EmptyObject = {[emptyObjectSymbol]?: never};
|
|
55
55
|
|
|
56
|
+
/**
|
|
57
|
+
Extract all optional keys from the given type.
|
|
58
|
+
|
|
59
|
+
This is useful when you want to create a new type that contains different type values for the optional keys only.
|
|
60
|
+
|
|
61
|
+
@example
|
|
62
|
+
```
|
|
63
|
+
import type {OptionalKeysOf, Except} from 'type-fest';
|
|
64
|
+
|
|
65
|
+
interface User {
|
|
66
|
+
name: string;
|
|
67
|
+
surname: string;
|
|
68
|
+
|
|
69
|
+
luckyNumber?: number;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const REMOVE_FIELD = Symbol('remove field symbol');
|
|
73
|
+
type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
|
|
74
|
+
[Key in OptionalKeysOf<Entity>]?: Entity[Key] | typeof REMOVE_FIELD;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const update1: UpdateOperation<User> = {
|
|
78
|
+
name: 'Alice'
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const update2: UpdateOperation<User> = {
|
|
82
|
+
name: 'Bob',
|
|
83
|
+
luckyNumber: REMOVE_FIELD
|
|
84
|
+
};
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
@category Utilities
|
|
88
|
+
*/
|
|
89
|
+
type OptionalKeysOf<BaseType extends object> =
|
|
90
|
+
BaseType extends unknown // For distributing `BaseType`
|
|
91
|
+
? (keyof {
|
|
92
|
+
[Key in keyof BaseType as BaseType extends Record<Key, BaseType[Key]> ? never : Key]: never
|
|
93
|
+
}) & (keyof BaseType) // Intersect with `keyof BaseType` to ensure result of `OptionalKeysOf<BaseType>` is always assignable to `keyof BaseType`
|
|
94
|
+
: never; // Should never happen
|
|
95
|
+
|
|
56
96
|
/**
|
|
57
97
|
Extract all required keys from the given type.
|
|
58
98
|
|
|
@@ -77,11 +117,10 @@ const validator2 = createValidation<User>('surname', value => value.length < 25)
|
|
|
77
117
|
|
|
78
118
|
@category Utilities
|
|
79
119
|
*/
|
|
80
|
-
type RequiredKeysOf<BaseType extends object> =
|
|
81
|
-
|
|
82
|
-
?
|
|
83
|
-
: never
|
|
84
|
-
}[keyof BaseType], undefined>;
|
|
120
|
+
type RequiredKeysOf<BaseType extends object> =
|
|
121
|
+
BaseType extends unknown // For distributing `BaseType`
|
|
122
|
+
? Exclude<keyof BaseType, OptionalKeysOf<BaseType>>
|
|
123
|
+
: never; // Should never happen
|
|
85
124
|
|
|
86
125
|
/**
|
|
87
126
|
Returns a boolean for whether the given type is `never`.
|
|
@@ -466,45 +505,6 @@ type IfAny<T, TypeIfAny = true, TypeIfNotAny = false> = (
|
|
|
466
505
|
IsAny<T> extends true ? TypeIfAny : TypeIfNotAny
|
|
467
506
|
);
|
|
468
507
|
|
|
469
|
-
/**
|
|
470
|
-
Extract all optional keys from the given type.
|
|
471
|
-
|
|
472
|
-
This is useful when you want to create a new type that contains different type values for the optional keys only.
|
|
473
|
-
|
|
474
|
-
@example
|
|
475
|
-
```
|
|
476
|
-
import type {OptionalKeysOf, Except} from 'type-fest';
|
|
477
|
-
|
|
478
|
-
interface User {
|
|
479
|
-
name: string;
|
|
480
|
-
surname: string;
|
|
481
|
-
|
|
482
|
-
luckyNumber?: number;
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
const REMOVE_FIELD = Symbol('remove field symbol');
|
|
486
|
-
type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
|
|
487
|
-
[Key in OptionalKeysOf<Entity>]?: Entity[Key] | typeof REMOVE_FIELD;
|
|
488
|
-
};
|
|
489
|
-
|
|
490
|
-
const update1: UpdateOperation<User> = {
|
|
491
|
-
name: 'Alice'
|
|
492
|
-
};
|
|
493
|
-
|
|
494
|
-
const update2: UpdateOperation<User> = {
|
|
495
|
-
name: 'Bob',
|
|
496
|
-
luckyNumber: REMOVE_FIELD
|
|
497
|
-
};
|
|
498
|
-
```
|
|
499
|
-
|
|
500
|
-
@category Utilities
|
|
501
|
-
*/
|
|
502
|
-
type OptionalKeysOf<BaseType extends object> = Exclude<{
|
|
503
|
-
[Key in keyof BaseType]: BaseType extends Record<Key, BaseType[Key]>
|
|
504
|
-
? never
|
|
505
|
-
: Key
|
|
506
|
-
}[keyof BaseType], undefined>;
|
|
507
|
-
|
|
508
508
|
/**
|
|
509
509
|
Matches any primitive, `void`, `Date`, or `RegExp` value.
|
|
510
510
|
*/
|
|
@@ -571,7 +571,11 @@ type ApplyDefaultOptions<
|
|
|
571
571
|
IfNever<SpecifiedOptions, Defaults,
|
|
572
572
|
Simplify<Merge<Defaults, {
|
|
573
573
|
[Key in keyof SpecifiedOptions
|
|
574
|
-
as Key extends OptionalKeysOf<Options>
|
|
574
|
+
as Key extends OptionalKeysOf<Options>
|
|
575
|
+
? Extract<SpecifiedOptions[Key], undefined> extends never
|
|
576
|
+
? Key
|
|
577
|
+
: never
|
|
578
|
+
: Key
|
|
575
579
|
]: SpecifiedOptions[Key]
|
|
576
580
|
}> & Required<Options>> // `& Required<Options>` ensures that `ApplyDefaultOptions<SomeOption, ...>` is always assignable to `Required<SomeOption>`
|
|
577
581
|
>>;
|
|
@@ -671,27 +675,29 @@ const partialSettings: PartialDeep<Settings, {recurseIntoArrays: true}> = {
|
|
|
671
675
|
type PartialDeep<T, Options extends PartialDeepOptions = {}> =
|
|
672
676
|
_PartialDeep<T, ApplyDefaultOptions<PartialDeepOptions, DefaultPartialDeepOptions, Options>>;
|
|
673
677
|
|
|
674
|
-
type _PartialDeep<T, Options extends Required<PartialDeepOptions>> = T extends BuiltIns | ((
|
|
678
|
+
type _PartialDeep<T, Options extends Required<PartialDeepOptions>> = T extends BuiltIns | ((new (...arguments_: any[]) => unknown))
|
|
675
679
|
? T
|
|
676
|
-
: T extends
|
|
677
|
-
?
|
|
678
|
-
: T extends
|
|
679
|
-
?
|
|
680
|
-
: T extends
|
|
681
|
-
?
|
|
682
|
-
: T extends
|
|
683
|
-
?
|
|
684
|
-
: T extends
|
|
685
|
-
?
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
680
|
+
: IsNever<keyof T> extends true // For functions with no properties
|
|
681
|
+
? T
|
|
682
|
+
: T extends Map<infer KeyType, infer ValueType>
|
|
683
|
+
? PartialMapDeep<KeyType, ValueType, Options>
|
|
684
|
+
: T extends Set<infer ItemType>
|
|
685
|
+
? PartialSetDeep<ItemType, Options>
|
|
686
|
+
: T extends ReadonlyMap<infer KeyType, infer ValueType>
|
|
687
|
+
? PartialReadonlyMapDeep<KeyType, ValueType, Options>
|
|
688
|
+
: T extends ReadonlySet<infer ItemType>
|
|
689
|
+
? PartialReadonlySetDeep<ItemType, Options>
|
|
690
|
+
: T extends object
|
|
691
|
+
? T extends ReadonlyArray<infer ItemType> // Test for arrays/tuples, per https://github.com/microsoft/TypeScript/issues/35156
|
|
692
|
+
? Options['recurseIntoArrays'] extends true
|
|
693
|
+
? ItemType[] extends T // Test for arrays (non-tuples) specifically
|
|
694
|
+
? readonly ItemType[] extends T // Differentiate readonly and mutable arrays
|
|
695
|
+
? ReadonlyArray<_PartialDeep<Options['allowUndefinedInNonTupleArrays'] extends false ? ItemType : ItemType | undefined, Options>>
|
|
696
|
+
: Array<_PartialDeep<Options['allowUndefinedInNonTupleArrays'] extends false ? ItemType : ItemType | undefined, Options>>
|
|
697
|
+
: PartialObjectDeep<T, Options> // Tuples behave properly
|
|
698
|
+
: T // If they don't opt into array testing, just use the original type
|
|
699
|
+
: PartialObjectDeep<T, Options>
|
|
700
|
+
: unknown;
|
|
695
701
|
|
|
696
702
|
/**
|
|
697
703
|
Same as `PartialDeep`, but accepts only `Map`s and as inputs. Internal helper for `PartialDeep`.
|
|
@@ -716,13 +722,16 @@ type PartialReadonlySetDeep<T, Options extends Required<PartialDeepOptions>> = {
|
|
|
716
722
|
/**
|
|
717
723
|
Same as `PartialDeep`, but accepts only `object`s as inputs. Internal helper for `PartialDeep`.
|
|
718
724
|
*/
|
|
719
|
-
type PartialObjectDeep<ObjectType extends object, Options extends Required<PartialDeepOptions>> =
|
|
720
|
-
|
|
721
|
-
|
|
725
|
+
type PartialObjectDeep<ObjectType extends object, Options extends Required<PartialDeepOptions>> =
|
|
726
|
+
(ObjectType extends (...arguments_: any) => unknown
|
|
727
|
+
? (...arguments_: Parameters<ObjectType>) => ReturnType<ObjectType>
|
|
728
|
+
: {}) & ({
|
|
729
|
+
[KeyType in keyof ObjectType]?: _PartialDeep<ObjectType[KeyType], Options>
|
|
730
|
+
});
|
|
722
731
|
|
|
723
732
|
interface RegleSchema<TState extends Record<string, any>, TSchema extends Record<string, any>, TShortcuts extends RegleShortcutDefinition = {}> {
|
|
724
733
|
/**
|
|
725
|
-
* r$ is a reactive object containing the values, errors, dirty state and all the necessary validations properties you'll need to display
|
|
734
|
+
* r$ is a reactive object containing the values, errors, dirty state and all the necessary validations properties you'll need to display information.
|
|
726
735
|
*
|
|
727
736
|
* To see the list of properties: {@link https://reglejs.dev/core-concepts/validation-properties}
|
|
728
737
|
*/
|
|
@@ -730,7 +739,7 @@ interface RegleSchema<TState extends Record<string, any>, TSchema extends Record
|
|
|
730
739
|
}
|
|
731
740
|
interface RegleSingleFieldSchema<TState extends Maybe<PrimitiveTypes>, TSchema extends unknown, TShortcuts extends RegleShortcutDefinition = {}> {
|
|
732
741
|
/**
|
|
733
|
-
* r$ is a reactive object containing the values, errors, dirty state and all the necessary validations properties you'll need to display
|
|
742
|
+
* r$ is a reactive object containing the values, errors, dirty state and all the necessary validations properties you'll need to display information.
|
|
734
743
|
*
|
|
735
744
|
* To see the list of properties: {@link https://reglejs.dev/core-concepts/validation-properties}
|
|
736
745
|
*/
|
|
@@ -801,7 +810,7 @@ type RegleSchemaFieldStatus<TSchema extends unknown, TState = any, TShortcuts ex
|
|
|
801
810
|
* @public
|
|
802
811
|
*/
|
|
803
812
|
type RegleSchemaCollectionStatus<TSchema extends Record<string, any>, TState extends any[], TShortcuts extends RegleShortcutDefinition = {}> = Omit<RegleSchemaFieldStatus<TSchema, TState, TShortcuts>, '$errors' | '$silentErrors' | '$validate'> & {
|
|
804
|
-
/** Collection of status
|
|
813
|
+
/** Collection of status for every item in your collection. Each item will be a field you can access or iterate to display your elements. */
|
|
805
814
|
readonly $each: Array<InferRegleSchemaStatusType<NonNullable<TSchema>, ArrayElement<TState>, TShortcuts>>;
|
|
806
815
|
/** 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. */
|
|
807
816
|
readonly $self: RegleSchemaFieldStatus<TSchema, TState, TShortcuts>;
|
|
@@ -811,7 +820,7 @@ type RegleSchemaCollectionStatus<TSchema extends Record<string, any>, TState ext
|
|
|
811
820
|
readonly $errors: RegleCollectionErrors<TSchema>;
|
|
812
821
|
/** Collection of all the error messages, collected for all children properties and nested forms. */
|
|
813
822
|
readonly $silentErrors: RegleCollectionErrors<TSchema>;
|
|
814
|
-
/** Will return a copy of your state with only the fields that are dirty. By default it will filter out nullish values or objects, but you can override it with the first parameter $extractDirtyFields(false). */
|
|
823
|
+
/** Will return a copy of your state with only the fields that are dirty. By default, it will filter out nullish values or objects, but you can override it with the first parameter $extractDirtyFields(false). */
|
|
815
824
|
$extractDirtyFields: (filterNullishValues?: boolean) => PartialDeep<TState>;
|
|
816
825
|
} & ([TShortcuts['collections']] extends [never] ? {} : {
|
|
817
826
|
[K in keyof TShortcuts['collections']]: ReturnType<NonNullable<TShortcuts['collections']>[K]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {useRootStorage}from'@regle/core';import {ref,computed,unref,isRef,watch}from'vue';function k(e){if(typeof e.source.flags=="string")return e.source.flags;{let t=[];return e.global&&t.push("g"),e.ignoreCase&&t.push("i"),e.multiline&&t.push("m"),e.sticky&&t.push("y"),e.unicode&&t.push("u"),t.join("")}}function f(e){let t=e,r={}.toString.call(e).slice(8,-1);if(r=="Set"&&(t=new Set([...e].map(a=>f(a)))),r=="Map"&&(t=new Map([...e].map(a=>[f(a[0]),f(a[1])]))),r=="Date"&&(t=new Date(e.getTime())),r=="RegExp"&&(t=RegExp(e.source,k(e))),r=="Array"||r=="Object"){t=Array.isArray(e)?[]:{};for(let a in e)t[a]=f(e[a]);}return t}function S(e){return e&&(e instanceof Date||e.constructor.name=="File"||e.constructor.name=="FileList")?false:typeof e=="object"&&e!==null&&!Array.isArray(e)}function v(e,t,r,a){var n,o;if(Array.isArray(t)&&(n=t.slice(0)),typeof t=="string"&&(n=t.split(".")),typeof t=="symbol"&&(n=[t]),!Array.isArray(n))throw new Error("props arg must be an array, a string or a symbol");if(o=n.pop(),!o)return false;w(o);for(var s;s=n.shift();)if(w(s),isNaN(parseInt(s))?(typeof e[s]>"u"&&(e[s]={}),e=e[s]):((e.$each??=[])[s]={},e=e.$each[s]),!e||typeof e!="object")return false;return a?e[o]?e[o].$self=(e[o].$self??=[]).concat(r):e[o]={...e[o],$self:r}:Array.isArray(e[o])?e[o]=e[o].concat(r):e[o]=r,true}function b(e,t,r){if(!e)return r;var a,n;if(Array.isArray(t)&&(a=t.slice(0)),typeof t=="string"&&(a=t.split(".")),typeof t=="symbol"&&(a=[t]),!Array.isArray(a))throw new Error("props arg must be an array, a string or a symbol");for(;a.length;)if(n=a.shift(),!e||!n||(e=e[n],e===void 0))return r;return e}function w(e){if(e=="__proto__"||e=="constructor"||e=="prototype")throw new Error("setting of prototype values not supported")}function g(e,t){let r={autoDirty:e?.autoDirty,lazy:e?.lazy,rewardEarly:e?.rewardEarly,clearExternalErrorsOnChange:e?.clearExternalErrorsOnChange};function a(n,o,s){let I=ref({}),p=computed(()=>unref(o)),A={...r,...s},M=computed(()=>!S(l.value)),l=isRef(n)?n:ref(n),C=ref(S(l.value)?{...f(l.value)}:f(l.value)),y=ref({}),T;if(!p.value?.["~standard"])throw new Error('Only "standard-schema" compatible libraries are supported');function V(i){let u={};return i.issues&&i.issues.map(c=>{let x=c.path?.map(d=>typeof d=="object"?d.key:d.toString()).join(".")??"",h=c.path?.[c.path.length-1],B=(typeof h=="object"&&"value"in h?Array.isArray(h.value):false)||("type"in c?c.type==="array":false)||Array.isArray(b(l.value,x));return {path:x,message:c.message,isArray:B}}).forEach(c=>{v(u,c.path,[c.message],c.isArray);}),u}async function D(){let i=p.value["~standard"].validate(l.value);return i instanceof Promise&&(i=await i),M.value?y.value=i.issues?.map(u=>u.message)??[]:y.value=V(i),i}return watch([l,p],D,{deep:true,immediate:true}),T=async()=>{try{return {valid:!(await D()).issues?.length,data:l.value}}catch(i){return Promise.reject(i)}},{r$:useRootStorage({scopeRules:I,state:l,options:A,schemaErrors:y,initialState:C,shortcuts:t,schemaMode:true,onValidate:T}).regle}}return a}var P=g();function F(e,t){return e}function R(){function e(t,r){return r}return e}var E=R();function N({modifiers:e,shortcuts:t}){let r=g(e,t),a=R();return {useRegleSchema:r,inferSchema:a}}export{N as defineRegleSchemaConfig,E as inferSchema,P as useRegleSchema,F as withDeps};
|
|
1
|
+
import {useRootStorage}from'@regle/core';import {ref,computed,unref,isRef,watch}from'vue';function k(e){if(typeof e.source.flags=="string")return e.source.flags;{let t=[];return e.global&&t.push("g"),e.ignoreCase&&t.push("i"),e.multiline&&t.push("m"),e.sticky&&t.push("y"),e.unicode&&t.push("u"),t.join("")}}function f(e){let t=e,r={}.toString.call(e).slice(8,-1);if(r=="Set"&&(t=new Set([...e].map(a=>f(a)))),r=="Map"&&(t=new Map([...e].map(a=>[f(a[0]),f(a[1])]))),r=="Date"&&(t=new Date(e.getTime())),r=="RegExp"&&(t=RegExp(e.source,k(e))),r=="Array"||r=="Object"){t=Array.isArray(e)?[]:{};for(let a in e)t[a]=f(e[a]);}return t}function S(e){return e&&(e instanceof Date||e.constructor.name=="File"||e.constructor.name=="FileList")?false:typeof e=="object"&&e!==null&&!Array.isArray(e)}function v(e,t,r,a){var n,o;if(Array.isArray(t)&&(n=t.slice(0)),typeof t=="string"&&(n=t.split(".")),typeof t=="symbol"&&(n=[t]),!Array.isArray(n))throw new Error("props arg must be an array, a string or a symbol");if(o=n.pop(),!o)return false;w(o);for(var s;s=n.shift();)if(w(s),isNaN(parseInt(s))?(typeof e[s]>"u"&&(e[s]={}),e=e[s]):((e.$each??=[])[s]={},e=e.$each[s]),!e||typeof e!="object")return false;return a?e[o]?e[o].$self=(e[o].$self??=[]).concat(r):e[o]={...e[o],$self:r}:Array.isArray(e[o])?e[o]=e[o].concat(r):e[o]=r,true}function b(e,t,r){if(!e)return r;var a,n;if(Array.isArray(t)&&(a=t.slice(0)),typeof t=="string"&&(a=t.split(".")),typeof t=="symbol"&&(a=[t]),!Array.isArray(a))throw new Error("props arg must be an array, a string or a symbol");for(;a.length;)if(n=a.shift(),!e||!n||(e=e[n],e===void 0))return r;return e}function w(e){if(e=="__proto__"||e=="constructor"||e=="prototype")throw new Error("setting of prototype values not supported")}function g(e,t){let r={autoDirty:e?.autoDirty,lazy:e?.lazy,rewardEarly:e?.rewardEarly,silent:e?.silent,clearExternalErrorsOnChange:e?.clearExternalErrorsOnChange};function a(n,o,s){let I=ref({}),p=computed(()=>unref(o)),A={...r,...s},M=computed(()=>!S(l.value)),l=isRef(n)?n:ref(n),C=ref(S(l.value)?{...f(l.value)}:f(l.value)),y=ref({}),T;if(!p.value?.["~standard"])throw new Error('Only "standard-schema" compatible libraries are supported');function V(i){let u={};return i.issues&&i.issues.map(c=>{let x=c.path?.map(d=>typeof d=="object"?d.key:d.toString()).join(".")??"",h=c.path?.[c.path.length-1],B=(typeof h=="object"&&"value"in h?Array.isArray(h.value):false)||("type"in c?c.type==="array":false)||Array.isArray(b(l.value,x));return {path:x,message:c.message,isArray:B}}).forEach(c=>{v(u,c.path,[c.message],c.isArray);}),u}async function D(){let i=p.value["~standard"].validate(l.value);return i instanceof Promise&&(i=await i),M.value?y.value=i.issues?.map(u=>u.message)??[]:y.value=V(i),i}return watch([l,p],D,{deep:true,immediate:true}),T=async()=>{try{return {valid:!(await D()).issues?.length,data:l.value}}catch(i){return Promise.reject(i)}},{r$:useRootStorage({scopeRules:I,state:l,options:A,schemaErrors:y,initialState:C,shortcuts:t,schemaMode:true,onValidate:T}).regle}}return a}var P=g();function F(e,t){return e}function R(){function e(t,r){return r}return e}var E=R();function N({modifiers:e,shortcuts:t}){let r=g(e,t),a=R();return {useRegleSchema:r,inferSchema:a}}export{N as defineRegleSchemaConfig,E as inferSchema,P as useRegleSchema,F as withDeps};
|
package/dist/regle-schemas.mjs
CHANGED
|
@@ -142,6 +142,7 @@ function createUseRegleSchemaComposable(options, shortcuts) {
|
|
|
142
142
|
autoDirty: options?.autoDirty,
|
|
143
143
|
lazy: options?.lazy,
|
|
144
144
|
rewardEarly: options?.rewardEarly,
|
|
145
|
+
silent: options?.silent,
|
|
145
146
|
clearExternalErrorsOnChange: options?.clearExternalErrorsOnChange
|
|
146
147
|
};
|
|
147
148
|
function useRegleSchema2(state, schema, options2) {
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@regle/schemas",
|
|
3
|
-
"version": "1.2.0-beta.
|
|
3
|
+
"version": "1.2.0-beta.3",
|
|
4
4
|
"description": "Schemas adapter for Regle",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@standard-schema/spec": "1.0.0",
|
|
7
|
-
"@regle/core": "1.2.0-beta.
|
|
8
|
-
"@regle/rules": "1.2.0-beta.
|
|
7
|
+
"@regle/core": "1.2.0-beta.3",
|
|
8
|
+
"@regle/rules": "1.2.0-beta.3"
|
|
9
9
|
},
|
|
10
10
|
"peerDependencies": {
|
|
11
11
|
"valibot": "^1.0.0",
|
|
@@ -25,23 +25,23 @@
|
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@total-typescript/ts-reset": "0.6.1",
|
|
28
|
-
"@types/node": "22.
|
|
28
|
+
"@types/node": "22.15.3",
|
|
29
29
|
"@typescript-eslint/eslint-plugin": "8.28.0",
|
|
30
30
|
"@typescript-eslint/parser": "8.28.0",
|
|
31
31
|
"@vue/test-utils": "2.4.6",
|
|
32
|
-
"eslint": "9.
|
|
32
|
+
"eslint": "9.25.1",
|
|
33
33
|
"eslint-config-prettier": "9.1.0",
|
|
34
|
-
"eslint-plugin-vue": "9.
|
|
34
|
+
"eslint-plugin-vue": "9.33.0",
|
|
35
35
|
"prettier": "3.5.3",
|
|
36
36
|
"tsup": "8.4.0",
|
|
37
|
-
"type-fest": "4.
|
|
38
|
-
"typescript": "5.8.
|
|
37
|
+
"type-fest": "4.40.1",
|
|
38
|
+
"typescript": "5.8.3",
|
|
39
39
|
"valibot": "1.0.0",
|
|
40
|
-
"vitest": "3.1.
|
|
40
|
+
"vitest": "3.1.2",
|
|
41
41
|
"vue": "3.5.13",
|
|
42
42
|
"vue-eslint-parser": "10.1.3",
|
|
43
|
-
"vue-tsc": "2.2.
|
|
44
|
-
"zod": "3.24.
|
|
43
|
+
"vue-tsc": "2.2.10",
|
|
44
|
+
"zod": "3.24.3"
|
|
45
45
|
},
|
|
46
46
|
"type": "module",
|
|
47
47
|
"exports": {
|