@regle/schemas 1.20.4 → 1.21.0-beta.2

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,10 +1,10 @@
1
1
  /**
2
- * @regle/schemas v1.20.4
2
+ * @regle/schemas v1.21.0-beta.2
3
3
  * (c) 2026 Victor Garcia
4
4
  * @license MIT
5
5
  */
6
6
 
7
- import { ArrayElement, CreateScopedUseRegleOptions, DeepMaybeRef, DeepPartial, DeepReactiveState, GlobalConfigOverrides, HasNamedKeys, HaveAnyRequiredProps, JoinDiscriminatedUnions, LocalRegleBehaviourOptions, Maybe, MaybeOutput, MergedScopedRegles, NoInferLegacy, PrimitiveTypes, RegleBehaviourOptions, RegleCollectionErrors, RegleCommonStatus, RegleErrorTree, RegleFieldIssue, RegleIssuesTree, RegleRuleStatus, RegleShortcutDefinition, RegleStaticImpl, TupleToPlainObj, UseScopedRegleOptions, useCollectScopeFn } from "@regle/core";
7
+ import { ArrayElement, CreateScopedUseRegleOptions, DeepMaybeRef, DeepPartial, DeepReactiveState, GlobalConfigOverrides, HasNamedKeys, HaveAnyRequiredProps, JoinDiscriminatedUnions, LocalRegleBehaviourOptions, Maybe, MaybeOutput, MergedScopedRegles, NoInferLegacy, PrimitiveTypes, RegleBehaviourOptions, RegleCollectionErrors, RegleCommonStatus, RegleErrorTree, RegleExternalCollectionErrors, RegleExternalSchemaErrorTree, RegleFieldIssue, RegleIssuesTree, RegleRuleStatus, RegleShortcutDefinition, RegleStaticImpl, TupleToPlainObj, UseScopedRegleOptions, useCollectScopeFn } from "@regle/core";
8
8
  import { MaybeRef, MaybeRefOrGetter, Raw, UnwrapNestedRefs } from "vue";
9
9
  import { StandardSchemaV1 } from "@standard-schema/spec";
10
10
  import { EmptyObject, IsAny, IsUnion, IsUnknown, UnionToTuple } from "type-fest";
@@ -55,7 +55,8 @@ type RegleSchemaStatus<TState extends Record<string, any> | undefined = Record<s
55
55
  *
56
56
  * Only contains errors from properties where $dirty equals true. */
57
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). */
58
+ readonly $silentErrors: RegleErrorTree<TState, false, true>; /** Sets the external errors for the field. */
59
+ $setExternalErrors(errors: RegleExternalSchemaErrorTree<TState>): void; /** 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). */
59
60
  $extractDirtyFields: (filterNullishValues?: boolean) => DeepPartial<TState>;
60
61
  } & ProcessNestedFields<JoinDiscriminatedUnions<TState>, TShortcuts> & (IsRoot extends true ? {
61
62
  /** 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>>>;
@@ -96,7 +97,8 @@ type RegleSchemaFieldStatus<TState = any, TShortcuts extends RegleShortcutDefini
96
97
  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 */
97
98
  readonly $rules: {
98
99
  [`~validator`]: RegleRuleStatus<TState, []>;
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). */
100
+ }; /** Sets the external errors for the field. */
101
+ $setExternalErrors(errors: string[]): void; /** 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). */
100
102
  $extractDirtyFields: (filterNullishValues?: boolean) => DeepPartial<TState>;
101
103
  } & ([TShortcuts['fields']] extends [never] ? {} : { [K in keyof TShortcuts['fields']]: ReturnType<NonNullable<TShortcuts['fields']>[K]> });
102
104
  /**
@@ -115,7 +117,10 @@ type RegleSchemaCollectionStatus<TState extends any[], TShortcuts extends RegleS
115
117
  *
116
118
  * Only contains errors from properties where $dirty equals true. */
117
119
  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). */
120
+ readonly $silentErrors: RegleCollectionErrors<TState>;
121
+ /** 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). */
122
+ /** Sets the external errors for the field. */
123
+ $setExternalErrors(errors: RegleExternalCollectionErrors<TState>): void; /** 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). */
119
124
  $extractDirtyFields: (filterNullishValues?: boolean) => DeepPartial<TState>;
120
125
  } & ([TShortcuts['collections']] extends [never] ? {} : { [K in keyof TShortcuts['collections']]: ReturnType<NonNullable<TShortcuts['collections']>[K]> });
121
126
  type RegleSchemaBehaviourOptions = {
@@ -1,19 +1,17 @@
1
1
  /**
2
- * @regle/schemas v1.20.4
2
+ * @regle/schemas v1.21.0-beta.2
3
3
  * (c) 2026 Victor Garcia
4
4
  * @license MIT
5
5
  */
6
6
 
7
7
  import { createScopedUseRegle, useRootStorage } from "@regle/core";
8
8
  import { computed, effectScope, getCurrentInstance, getCurrentScope, isRef, nextTick, onMounted, onScopeDispose, reactive, ref, toValue, unref, watch } from "vue";
9
-
10
9
  /**
11
10
  * Server side friendly way of checking for a File
12
11
  */
13
12
  function isFile(value) {
14
13
  return value?.constructor?.name == "File";
15
14
  }
16
-
17
15
  function isObject(obj) {
18
16
  if (obj && (obj instanceof Date || obj.constructor.name == "File" || obj.constructor.name == "FileList")) return false;
19
17
  return typeof obj === "object" && obj !== null && !Array.isArray(obj);
@@ -82,7 +80,6 @@ function merge(_obj1, ..._objs) {
82
80
  }
83
81
  return result;
84
82
  }
85
-
86
83
  /**
87
84
  * Checks if a value is empty in any way (including arrays and objects).
88
85
  * This is the inverse of `isFilled`.
@@ -127,7 +124,6 @@ function isEmpty(value, considerEmptyArrayInvalid = true, considerEmptyObjectInv
127
124
  }
128
125
  return !String(value).length;
129
126
  }
130
-
131
127
  function getRegExpFlags(regExp) {
132
128
  let flags = [];
133
129
  if (regExp.global) flags.push("g");
@@ -151,7 +147,6 @@ function cloneDeep(obj, dep = 0) {
151
147
  }
152
148
  return result;
153
149
  }
154
-
155
150
  /**
156
151
  * Converts ref to reactive.
157
152
  *
@@ -197,7 +192,6 @@ function toReactive(objectRef, isDisabled) {
197
192
  }
198
193
  }));
199
194
  }
200
-
201
195
  function getIssuePath(issue) {
202
196
  return issue.path?.map((item) => typeof item === "object" ? item.key : item.toString()).join(".") ?? "";
203
197
  }
@@ -229,7 +223,6 @@ function getPropertiesFromIssue(issue, processedState) {
229
223
  lastItem
230
224
  };
231
225
  }
232
-
233
226
  function filterIssues(issues, previousIssues, rewardEarly, isValidate = false) {
234
227
  if (!isValidate && rewardEarly) {
235
228
  if (previousIssues.value.length) return previousIssues.value.reduce((acc, prevIssue) => {
@@ -291,7 +284,6 @@ function issuesToRegleErrors({ result, previousIssues, processedState, rewardEar
291
284
  } else previousIssues.value = [];
292
285
  return output;
293
286
  }
294
-
295
287
  function createSchemaState(state) {
296
288
  const processedState = isRef(state) ? state : ref(state);
297
289
  return {
@@ -301,7 +293,6 @@ function createSchemaState(state) {
301
293
  originalState: isObject(processedState.value) ? { ...cloneDeep(processedState.value) } : cloneDeep(processedState.value)
302
294
  };
303
295
  }
304
-
305
296
  function createSchemaValidationRunner({ processedState, getSchema, isSingleField, customErrors, previousIssues, resolvedOptions, syncOnUpdate, syncOnValidate }) {
306
297
  let unWatchState;
307
298
  function defineWatchState() {
@@ -343,7 +334,6 @@ function createSchemaValidationRunner({ processedState, getSchema, isSingleField
343
334
  stopWatching
344
335
  };
345
336
  }
346
-
347
337
  function createUseRegleSchemaComposable(params) {
348
338
  const { options: modifiers, shortcuts, overrides } = params ?? {};
349
339
  function useRegleSchema(state, schema, options) {
@@ -475,7 +465,6 @@ function createUseRegleSchemaComposable(params) {
475
465
  * @see {@link https://reglejs.dev/integrations/schemas-libraries Documentation}
476
466
  */
477
467
  const useRegleSchema = createUseRegleSchemaComposable();
478
-
479
468
  /**
480
469
  * Force a schema validation to re-run when specified dependencies change.
481
470
  * Useful when your schema depends on reactive values that aren't automatically tracked.
@@ -509,7 +498,6 @@ const useRegleSchema = createUseRegleSchemaComposable();
509
498
  function withDeps(schema, _depsArray) {
510
499
  return schema;
511
500
  }
512
-
513
501
  function createInferSchemaHelper() {
514
502
  function inferSchema(state, rulesFactory) {
515
503
  return rulesFactory;
@@ -544,7 +532,6 @@ function createInferSchemaHelper() {
544
532
  * @see {@link https://reglejs.dev/integrations/schemas-libraries Documentation}
545
533
  */
546
534
  const inferSchema = createInferSchemaHelper();
547
-
548
535
  /**
549
536
  * Define a global configuration for `useRegleSchema`.
550
537
  *
@@ -581,7 +568,6 @@ function defineRegleSchemaConfig({ modifiers, shortcuts, overrides }) {
581
568
  inferSchema: createInferSchemaHelper()
582
569
  };
583
570
  }
584
-
585
571
  /**
586
572
  * Create a scoped validation system for schema-based validation.
587
573
  * Similar to `createScopedUseRegle` but for use with Standard Schema libraries.
@@ -616,5 +602,4 @@ const createScopedUseRegleSchema = (options) => {
616
602
  const { useCollectScope: _useCollectSchemaScope, useScopedRegle: _useScopedRegleSchema } = createScopedUseRegle({ customUseRegle: useRegleSchema });
617
603
  const useCollectSchemaScope = _useCollectSchemaScope;
618
604
  const useScopedRegleSchema = _useScopedRegleSchema;
619
-
620
- export { createScopedUseRegleSchema, defineRegleSchemaConfig, inferSchema, useCollectSchemaScope, useRegleSchema, useScopedRegleSchema, withDeps };
605
+ export { createScopedUseRegleSchema, defineRegleSchemaConfig, inferSchema, useCollectSchemaScope, useRegleSchema, useScopedRegleSchema, withDeps };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @regle/schemas v1.20.4
2
+ * @regle/schemas v1.21.0-beta.2
3
3
  * (c) 2026 Victor Garcia
4
4
  * @license MIT
5
5
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@regle/schemas",
3
- "version": "1.20.4",
3
+ "version": "1.21.0-beta.2",
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.4",
40
- "@regle/core": "1.20.4",
41
- "@regle/rules": "1.20.4"
39
+ "type-fest": "5.5.0",
40
+ "@regle/core": "1.21.0-beta.2",
41
+ "@regle/rules": "1.21.0-beta.2"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@total-typescript/ts-reset": "0.6.1",
45
45
  "@types/node": "24.12.0",
46
46
  "@typescript/native-preview": "7.0.0-dev.20260317.1",
47
47
  "@vue/test-utils": "2.4.6",
48
- "tsdown": "0.20.3",
49
- "type-fest": "5.4.4",
48
+ "tsdown": "0.21.4",
49
+ "type-fest": "5.5.0",
50
50
  "typescript": "5.9.3",
51
- "valibot": "1.2.0",
51
+ "valibot": "1.3.1",
52
52
  "vitest": "4.1.0",
53
53
  "vue": "3.5.30",
54
- "vue-tsc": "3.2.5",
54
+ "vue-tsc": "3.2.6",
55
55
  "zod": "4.3.6"
56
56
  },
57
57
  "peerDependencies": {