@regle/schemas 1.18.0-beta.4 → 1.18.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-schemas.d.ts +17 -33
- package/dist/regle-schemas.js +6 -6
- package/dist/regle-schemas.min.js +1 -1
- package/package.json +10 -10
package/dist/regle-schemas.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @regle/schemas v1.18.
|
|
2
|
+
* @regle/schemas v1.18.1
|
|
3
3
|
* (c) 2026 Victor Garcia
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
@@ -27,8 +27,7 @@ type RegleSingleFieldSchema<TState extends Maybe<PrimitiveTypes>, TSchema extend
|
|
|
27
27
|
* To see the list of properties: {@link https://reglejs.dev/core-concepts/validation-properties}
|
|
28
28
|
*/
|
|
29
29
|
r$: Raw<RegleSchemaFieldStatus<TState, TShortcuts> & {
|
|
30
|
-
/** 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).
|
|
31
|
-
$validate: (forceValues?: TState extends EmptyObject ? any : HasNamedKeys<TState> extends true ? TState : any) => Promise<RegleSchemaResult<StandardSchemaV1.InferOutput<TSchema>>>;
|
|
30
|
+
/** 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). */$validate: (forceValues?: TState extends EmptyObject ? any : HasNamedKeys<TState> extends true ? TState : any) => Promise<RegleSchemaResult<StandardSchemaV1.InferOutput<TSchema>>>;
|
|
32
31
|
}>;
|
|
33
32
|
} & TAdditionalReturnProperties;
|
|
34
33
|
type RegleSchemaResult<TSchema extends unknown> = {
|
|
@@ -47,8 +46,7 @@ type ProcessNestedFields<TState extends Record<string, any> | undefined, TShortc
|
|
|
47
46
|
* @public
|
|
48
47
|
*/
|
|
49
48
|
type RegleSchemaStatus<TState extends Record<string, any> | undefined = Record<string, any>, TSchema extends StandardSchemaV1 = StandardSchemaV1, TShortcuts extends RegleShortcutDefinition = {}, IsRoot extends boolean = false> = Omit<RegleCommonStatus<TState>, IsRoot extends false ? '$pending' : ''> & {
|
|
50
|
-
/** 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. */
|
|
51
|
-
readonly $fields: ProcessNestedFields<JoinDiscriminatedUnions<TState>, TShortcuts>;
|
|
49
|
+
/** 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. */readonly $fields: ProcessNestedFields<JoinDiscriminatedUnions<TState>, TShortcuts>;
|
|
52
50
|
/** Collection of all issues, collected for all children properties and nested forms.
|
|
53
51
|
*
|
|
54
52
|
* Only contains errors from properties where $dirty equals true. */
|
|
@@ -56,14 +54,11 @@ type RegleSchemaStatus<TState extends Record<string, any> | undefined = Record<s
|
|
|
56
54
|
/** Collection of all the error messages, collected for all children properties and nested forms.
|
|
57
55
|
*
|
|
58
56
|
* Only contains errors from properties where $dirty equals true. */
|
|
59
|
-
readonly $errors: RegleErrorTree<TState, false, true>;
|
|
60
|
-
/**
|
|
61
|
-
readonly $silentErrors: RegleErrorTree<TState, false, true>;
|
|
62
|
-
/** 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). */
|
|
57
|
+
readonly $errors: RegleErrorTree<TState, false, true>; /** Collection of all the error messages, collected for all children properties. */
|
|
58
|
+
readonly $silentErrors: RegleErrorTree<TState, false, true>; /** 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). */
|
|
63
59
|
$extractDirtyFields: (filterNullishValues?: boolean) => DeepPartial<TState>;
|
|
64
60
|
} & ProcessNestedFields<JoinDiscriminatedUnions<TState>, TShortcuts> & (IsRoot extends true ? {
|
|
65
|
-
/** 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).
|
|
66
|
-
$validate: (forceValues?: TState extends EmptyObject ? (HasNamedKeys<TState> extends true ? TState : any) : TState) => Promise<RegleSchemaResult<StandardSchemaV1.InferOutput<TSchema>>>;
|
|
61
|
+
/** 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). */$validate: (forceValues?: TState extends EmptyObject ? (HasNamedKeys<TState> extends true ? TState : any) : TState) => Promise<RegleSchemaResult<StandardSchemaV1.InferOutput<TSchema>>>;
|
|
67
62
|
} : {}) & ([TShortcuts['nested']] extends [never] ? {} : { [K in keyof TShortcuts['nested']]: ReturnType<NonNullable<TShortcuts['nested']>[K]> });
|
|
68
63
|
/**
|
|
69
64
|
* @public
|
|
@@ -73,9 +68,7 @@ type InferRegleSchemaStatusType<TState extends unknown, TShortcuts extends Regle
|
|
|
73
68
|
* @public
|
|
74
69
|
*/
|
|
75
70
|
type RegleSchemaFieldStatus<TState = any, TShortcuts extends RegleShortcutDefinition = {}> = Omit<RegleCommonStatus<TState>, '$pending' | '$value' | '$silentValue' | '$initialValue' | '$originalValue'> & {
|
|
76
|
-
/** A reference to the original validated model. It can be used to bind your form with v-model
|
|
77
|
-
$value: MaybeOutput<UnwrapNestedRefs<TState>>;
|
|
78
|
-
/** $value variant that will not "touch" the field and update the value silently, running only the rules, so you can easily swap values without impacting user interaction. */
|
|
71
|
+
/** A reference to the original validated model. It can be used to bind your form with v-model.*/$value: MaybeOutput<UnwrapNestedRefs<TState>>; /** $value variant that will not "touch" the field and update the value silently, running only the rules, so you can easily swap values without impacting user interaction. */
|
|
79
72
|
$silentValue: MaybeOutput<UnwrapNestedRefs<TState>>;
|
|
80
73
|
/**
|
|
81
74
|
* This value reflect the current initial value of the field.
|
|
@@ -89,8 +82,7 @@ type RegleSchemaFieldStatus<TState = any, TShortcuts extends RegleShortcutDefini
|
|
|
89
82
|
/** Collection of all the error messages, collected for all children properties and nested forms.
|
|
90
83
|
*
|
|
91
84
|
* Only contains errors from properties where $dirty equals true. */
|
|
92
|
-
readonly $errors: string[];
|
|
93
|
-
/** Collection of all the error messages, collected for all children properties and nested forms. */
|
|
85
|
+
readonly $errors: string[]; /** Collection of all the error messages, collected for all children properties and nested forms. */
|
|
94
86
|
readonly $silentErrors: string[];
|
|
95
87
|
/**
|
|
96
88
|
* Collect all metadata of validators, Only contains errors from properties where $dirty equals true.
|
|
@@ -99,25 +91,19 @@ type RegleSchemaFieldStatus<TState = any, TShortcuts extends RegleShortcutDefini
|
|
|
99
91
|
/**
|
|
100
92
|
* Collect all metadata of validators, including the error message.
|
|
101
93
|
*/
|
|
102
|
-
readonly $silentIssues: (RegleFieldIssue & StandardSchemaV1.Issue)[];
|
|
103
|
-
|
|
104
|
-
readonly $
|
|
105
|
-
/** Represents the inactive status. Is true when this state have empty rules */
|
|
106
|
-
readonly $inactive: boolean;
|
|
107
|
-
/** This is reactive tree containing all the declared rules of your field. To know more about the rule properties check the rules properties section */
|
|
94
|
+
readonly $silentIssues: (RegleFieldIssue & StandardSchemaV1.Issue)[]; /** 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). */
|
|
95
|
+
readonly $externalErrors?: string[]; /** Represents the inactive status. Is true when this state have empty rules */
|
|
96
|
+
readonly $inactive: boolean; /** This is reactive tree containing all the declared rules of your field. To know more about the rule properties check the rules properties section */
|
|
108
97
|
readonly $rules: {
|
|
109
98
|
[`~validator`]: RegleRuleStatus<TState, []>;
|
|
110
|
-
};
|
|
111
|
-
/** 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). */
|
|
99
|
+
}; /** 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). */
|
|
112
100
|
$extractDirtyFields: (filterNullishValues?: boolean) => DeepPartial<TState>;
|
|
113
101
|
} & ([TShortcuts['fields']] extends [never] ? {} : { [K in keyof TShortcuts['fields']]: ReturnType<NonNullable<TShortcuts['fields']>[K]> });
|
|
114
102
|
/**
|
|
115
103
|
* @public
|
|
116
104
|
*/
|
|
117
105
|
type RegleSchemaCollectionStatus<TState extends any[], TShortcuts extends RegleShortcutDefinition = {}> = Omit<RegleSchemaFieldStatus<TState, TShortcuts>, '$errors' | '$silentErrors' | '$validate'> & {
|
|
118
|
-
/** Collection of status for every item in your collection. Each item will be a field you can access or iterate to display your elements. */
|
|
119
|
-
readonly $each: Array<InferRegleSchemaStatusType<ArrayElement<TState>, TShortcuts>>;
|
|
120
|
-
/** 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. */
|
|
106
|
+
/** Collection of status for every item in your collection. Each item will be a field you can access or iterate to display your elements. */readonly $each: Array<InferRegleSchemaStatusType<ArrayElement<TState>, TShortcuts>>; /** 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. */
|
|
121
107
|
readonly $self: RegleSchemaFieldStatus<TState, TShortcuts>;
|
|
122
108
|
/**
|
|
123
109
|
* Collection of all the issues, collected for all children properties and nested forms.
|
|
@@ -128,10 +114,8 @@ type RegleSchemaCollectionStatus<TState extends any[], TShortcuts extends RegleS
|
|
|
128
114
|
/** Collection of all the error messages, collected for all children properties and nested forms.
|
|
129
115
|
*
|
|
130
116
|
* Only contains errors from properties where $dirty equals true. */
|
|
131
|
-
readonly $errors: RegleCollectionErrors<TState>;
|
|
132
|
-
/**
|
|
133
|
-
readonly $silentErrors: RegleCollectionErrors<TState>;
|
|
134
|
-
/** 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). */
|
|
117
|
+
readonly $errors: RegleCollectionErrors<TState>; /** Collection of all the error messages, collected for all children properties and nested forms. */
|
|
118
|
+
readonly $silentErrors: RegleCollectionErrors<TState>; /** 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). */
|
|
135
119
|
$extractDirtyFields: (filterNullishValues?: boolean) => DeepPartial<TState>;
|
|
136
120
|
} & ([TShortcuts['collections']] extends [never] ? {} : { [K in keyof TShortcuts['collections']]: ReturnType<NonNullable<TShortcuts['collections']>[K]> });
|
|
137
121
|
type RegleSchemaBehaviourOptions = {
|
|
@@ -149,9 +133,9 @@ type RegleSchemaBehaviourOptions = {
|
|
|
149
133
|
onValidate?: boolean;
|
|
150
134
|
};
|
|
151
135
|
};
|
|
152
|
-
type useRegleSchemaFnOptions<TAdditionalOptions extends Record<string, any>> = Omit<Partial<DeepMaybeRef<RegleBehaviourOptions>> & LocalRegleBehaviourOptions<
|
|
136
|
+
type useRegleSchemaFnOptions<TSchema extends Record<string, any>, TAdditionalOptions extends Record<string, any>> = Omit<Partial<DeepMaybeRef<RegleBehaviourOptions>> & LocalRegleBehaviourOptions<TSchema, {}, never>, 'validationGroups' | 'lazy'> & RegleSchemaBehaviourOptions & TAdditionalOptions;
|
|
153
137
|
interface useRegleSchemaFn<TShortcuts extends RegleShortcutDefinition<any> = never, TAdditionalReturnProperties extends Record<string, any> = {}, TAdditionalOptions extends Record<string, any> = {}> {
|
|
154
|
-
<TSchema extends StandardSchemaV1, TState extends StandardSchemaV1.InferInput<TSchema> | undefined>(...params: [state: MaybeRef<DeepPartial<NoInferLegacy<TState>>> | DeepReactiveState<DeepPartial<NoInferLegacy<TState>>>, rulesFactory: MaybeRef<TSchema>, ...(HaveAnyRequiredProps<useRegleSchemaFnOptions<TAdditionalOptions>> extends true ? [options: useRegleSchemaFnOptions<TAdditionalOptions>] : [options?: useRegleSchemaFnOptions<TAdditionalOptions>])]): NonNullable<TState> extends PrimitiveTypes ? RegleSingleFieldSchema<NonNullable<TState>, TSchema, TShortcuts, TAdditionalReturnProperties> : RegleSchema<UnwrapNestedRefs<NonNullable<TState>>, TSchema, TShortcuts, TAdditionalReturnProperties>;
|
|
138
|
+
<TSchema extends StandardSchemaV1, TState extends StandardSchemaV1.InferInput<TSchema> | undefined>(...params: [state: MaybeRef<DeepPartial<NoInferLegacy<TState>>> | DeepReactiveState<DeepPartial<NoInferLegacy<TState>>>, rulesFactory: MaybeRef<TSchema>, ...(HaveAnyRequiredProps<useRegleSchemaFnOptions<NoInferLegacy<NonNullable<TState>>, TAdditionalOptions>> extends true ? [options: useRegleSchemaFnOptions<NoInferLegacy<NonNullable<TState>>, TAdditionalOptions>] : [options?: useRegleSchemaFnOptions<NoInferLegacy<NonNullable<TState>>, TAdditionalOptions>])]): NonNullable<TState> extends PrimitiveTypes ? RegleSingleFieldSchema<NonNullable<TState>, TSchema, TShortcuts, TAdditionalReturnProperties> : RegleSchema<UnwrapNestedRefs<NonNullable<TState>>, TSchema, TShortcuts, TAdditionalReturnProperties>;
|
|
155
139
|
}
|
|
156
140
|
/**
|
|
157
141
|
* `useRegleSchema` enables validation using Standard Schema compatible libraries
|
package/dist/regle-schemas.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @regle/schemas v1.18.
|
|
2
|
+
* @regle/schemas v1.18.1
|
|
3
3
|
* (c) 2026 Victor Garcia
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
@@ -160,12 +160,12 @@ function createUseRegleSchemaComposable(params) {
|
|
|
160
160
|
rewardEarly: options?.rewardEarly,
|
|
161
161
|
clearExternalErrorsOnChange: options?.clearExternalErrorsOnChange
|
|
162
162
|
};
|
|
163
|
-
function useRegleSchema
|
|
163
|
+
function useRegleSchema(state, schema, options) {
|
|
164
164
|
const computedSchema = computed(() => unref(schema));
|
|
165
165
|
const { syncState = {
|
|
166
166
|
onUpdate: false,
|
|
167
167
|
onValidate: false
|
|
168
|
-
}, ...defaultOptions } = options
|
|
168
|
+
}, ...defaultOptions } = options ?? {};
|
|
169
169
|
const { onUpdate: syncOnUpdate = false, onValidate: syncOnValidate = false } = syncState;
|
|
170
170
|
const resolvedOptions = {
|
|
171
171
|
...globalOptions,
|
|
@@ -323,7 +323,7 @@ function createUseRegleSchemaComposable(params) {
|
|
|
323
323
|
});
|
|
324
324
|
return { r$: regle.regle };
|
|
325
325
|
}
|
|
326
|
-
return useRegleSchema
|
|
326
|
+
return useRegleSchema;
|
|
327
327
|
}
|
|
328
328
|
/**
|
|
329
329
|
* `useRegleSchema` enables validation using Standard Schema compatible libraries
|
|
@@ -403,10 +403,10 @@ function withDeps(schema, _depsArray) {
|
|
|
403
403
|
}
|
|
404
404
|
|
|
405
405
|
function createInferSchemaHelper() {
|
|
406
|
-
function inferSchema
|
|
406
|
+
function inferSchema(state, rulesFactory) {
|
|
407
407
|
return rulesFactory;
|
|
408
408
|
}
|
|
409
|
-
return inferSchema
|
|
409
|
+
return inferSchema;
|
|
410
410
|
}
|
|
411
411
|
/**
|
|
412
412
|
* Type helper to provide autocomplete and type-checking for your schema.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@regle/schemas",
|
|
3
|
-
"version": "1.18.
|
|
3
|
+
"version": "1.18.1",
|
|
4
4
|
"description": "Schemas adapter for Regle",
|
|
5
5
|
"homepage": "https://reglejs.dev/",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,22 +36,22 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@standard-schema/spec": "1.1.0",
|
|
39
|
-
"type-fest": "5.4.
|
|
40
|
-
"@regle/
|
|
41
|
-
"@regle/
|
|
39
|
+
"type-fest": "5.4.3",
|
|
40
|
+
"@regle/rules": "1.18.1",
|
|
41
|
+
"@regle/core": "1.18.1"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@total-typescript/ts-reset": "0.6.1",
|
|
45
|
-
"@types/node": "
|
|
45
|
+
"@types/node": "24.1.0",
|
|
46
46
|
"@vue/test-utils": "2.4.6",
|
|
47
|
-
"tsdown": "0.
|
|
48
|
-
"type-fest": "5.4.
|
|
47
|
+
"tsdown": "0.20.1",
|
|
48
|
+
"type-fest": "5.4.3",
|
|
49
49
|
"typescript": "5.9.3",
|
|
50
50
|
"valibot": "1.2.0",
|
|
51
|
-
"vitest": "4.0.
|
|
51
|
+
"vitest": "4.0.18",
|
|
52
52
|
"vue": "3.5.27",
|
|
53
|
-
"vue-tsc": "3.2.
|
|
54
|
-
"zod": "4.3.
|
|
53
|
+
"vue-tsc": "3.2.4",
|
|
54
|
+
"zod": "4.3.6"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"arktype": "^2.1.0",
|