@regle/rules 1.10.1 → 1.11.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,8 +1,6 @@
1
1
  import { AllRulesDeclarations, CommonAlphaOptions, CommonComparisonOptions, FormRuleDeclaration, InlineRuleDeclaration, Maybe, MaybeInput, MaybeReadonly, NonEmptyTuple, RegleRuleDecl, RegleRuleDefinition, RegleRuleDefinitionWithMetadataProcessor, RegleRuleMetadataConsumer, RegleRuleMetadataDefinition, RegleRuleWithParamsDefinition, UnwrapRegleUniversalParams } from "@regle/core";
2
2
  import { ComputedRef, MaybeRef, MaybeRefOrGetter, Ref } from "vue";
3
-
4
- //#region src/helpers/withMessage.d.ts
5
-
3
+ import { EmptyObject } from "type-fest";
6
4
  /**
7
5
  * The withMessage wrapper lets you associate an error message with a rule. Pass your rule as the first argument and the error message as the second.
8
6
  *
@@ -24,16 +22,12 @@ declare function withMessage<TValue extends any, TParams extends any[], TReturn
24
22
  declare function withMessage<TValue extends any, TParams extends unknown[], TReturn extends RegleRuleMetadataDefinition | Promise<RegleRuleMetadataDefinition>, TMetadata extends RegleRuleMetadataDefinition = (TReturn extends Promise<infer M> ? M : TReturn), TAsync extends boolean = (TReturn extends Promise<any> ? true : false)>(rule: RegleRuleDefinition<TValue, TParams, TAsync, TMetadata>, newMessage: RegleRuleDefinitionWithMetadataProcessor<TValue, RegleRuleMetadataConsumer<TValue, TParams, TMetadata>, string | string[]>): RegleRuleDefinition<TValue, TParams, TAsync, TMetadata>;
25
23
  declare function withMessage<TValue extends any, TParams extends any[], TReturn extends RegleRuleMetadataDefinition | Promise<RegleRuleMetadataDefinition>, TAsync extends boolean = (TReturn extends Promise<any> ? true : false)>(rule: InlineRuleDeclaration<TValue, TParams, TReturn>, newMessage: RegleRuleDefinitionWithMetadataProcessor<TValue, RegleRuleMetadataConsumer<TValue, TParams, TReturn extends Promise<infer M> ? M : TReturn>, string | string[]>): RegleRuleDefinition<TValue, TParams, TAsync, TReturn extends Promise<infer M> ? M : TReturn>;
26
24
  declare function withMessage<TValue extends any, TParams extends any[], TReturn extends RegleRuleMetadataDefinition | Promise<RegleRuleMetadataDefinition>, TMetadata extends RegleRuleMetadataDefinition = (TReturn extends Promise<infer M> ? M : TReturn), TAsync extends boolean = (TReturn extends Promise<any> ? true : false)>(rule: (...args: any[]) => RegleRuleDefinition<TValue, TParams, TAsync, TMetadata>, newMessage: RegleRuleDefinitionWithMetadataProcessor<TValue, RegleRuleMetadataConsumer<TValue, TParams, TMetadata>, string | string[]>): RegleRuleWithParamsDefinition<TValue, TParams, TAsync, TMetadata>;
27
- //#endregion
28
- //#region src/helpers/withTooltip.d.ts
29
25
  /**
30
26
  * The withTooltip wrapper allows you to display additional messages for your field that aren’t necessarily errors. Tooltips are aggregated and accessible via $fields.xxx.$tooltips .
31
27
  */
32
28
  declare function withTooltip<TValue extends any, TParams extends any[], TReturn extends RegleRuleMetadataDefinition | Promise<RegleRuleMetadataDefinition>, TMetadata extends RegleRuleMetadataDefinition = (TReturn extends Promise<infer M> ? M : TReturn), TAsync extends boolean = (TReturn extends Promise<any> ? true : false)>(rule: RegleRuleWithParamsDefinition<TValue, TParams, TAsync, TMetadata>, newTooltip: RegleRuleDefinitionWithMetadataProcessor<TValue, RegleRuleMetadataConsumer<TValue, TParams, TMetadata>, string | string[]>): RegleRuleWithParamsDefinition<TValue, TParams, TAsync, TMetadata>;
33
29
  declare function withTooltip<TValue extends any, TParams extends any[], TReturn extends RegleRuleMetadataDefinition | Promise<RegleRuleMetadataDefinition>, TMetadata extends RegleRuleMetadataDefinition = (TReturn extends Promise<infer M> ? M : TReturn), TAsync extends boolean = (TReturn extends Promise<any> ? true : false)>(rule: RegleRuleDefinition<TValue, TParams, TAsync, TMetadata>, newTooltip: RegleRuleDefinitionWithMetadataProcessor<TValue, RegleRuleMetadataConsumer<TValue, TParams, TMetadata>, string | string[]>): RegleRuleDefinition<TValue, TParams, TAsync, TMetadata>;
34
30
  declare function withTooltip<TValue extends any, TParams extends any[], TReturn extends RegleRuleMetadataDefinition | Promise<RegleRuleMetadataDefinition>, TAsync extends boolean = (TReturn extends Promise<any> ? true : false)>(rule: InlineRuleDeclaration<TValue, TParams, TReturn>, newTooltip: RegleRuleDefinitionWithMetadataProcessor<TValue, RegleRuleMetadataConsumer<TValue, TParams, TReturn extends Promise<infer M> ? M : TReturn>, string | string[]>): RegleRuleDefinition<TValue, TParams, TAsync, TReturn extends Promise<infer M> ? M : TReturn>;
35
- //#endregion
36
- //#region src/helpers/withAsync.d.ts
37
31
  /**
38
32
  * withAsync works like withParams, but is specifically designed for async rules that depend on external values.
39
33
  *
@@ -54,8 +48,6 @@ declare function withTooltip<TValue extends any, TParams extends any[], TReturn
54
48
  */
55
49
  declare function withAsync<TValue, TParams extends (Ref<unknown> | (() => unknown))[] = [], TReturn extends Promise<RegleRuleMetadataDefinition> = Promise<RegleRuleMetadataDefinition>, TMetadata extends RegleRuleMetadataDefinition = (TReturn extends Promise<infer M> ? M : TReturn)>(rule: InlineRuleDeclaration<TValue, TParams, TReturn>, depsArray?: [...TParams]): RegleRuleDefinition<TValue, UnwrapRegleUniversalParams<TParams>, true, TMetadata>;
56
50
  declare function withAsync<TValue extends any, TParams extends any[], TMetadata extends RegleRuleMetadataDefinition>(rule: RegleRuleWithParamsDefinition<TValue, TParams, true, TMetadata>, depsArray?: [...TParams]): RegleRuleWithParamsDefinition<TValue, TParams, true, TMetadata>;
57
- //#endregion
58
- //#region src/helpers/withParams.d.ts
59
51
  /**
60
52
  * The withParams wrapper allows your rule to depend on external parameters, such as a reactive property in your component or store.
61
53
  *
@@ -78,8 +70,6 @@ declare function withAsync<TValue extends any, TParams extends any[], TMetadata
78
70
  */
79
71
  declare function withParams<TValue, TParams extends (Ref<unknown> | (() => unknown))[] = [], TReturn extends RegleRuleMetadataDefinition = RegleRuleMetadataDefinition, TMetadata extends RegleRuleMetadataDefinition = (TReturn extends Promise<infer M> ? M : TReturn), TAsync extends boolean = (TReturn extends Promise<any> ? true : false)>(rule: InlineRuleDeclaration<TValue, TParams, TReturn> | RegleRuleDefinition<TValue, any[], TAsync, TMetadata>, depsArray: [...TParams]): RegleRuleDefinition<TValue, UnwrapRegleUniversalParams<TParams>, TAsync, TMetadata>;
80
72
  declare function withParams<TValue extends any, TParams extends any[], TReturn extends RegleRuleMetadataDefinition = RegleRuleMetadataDefinition, TMetadata extends RegleRuleMetadataDefinition = (TReturn extends Promise<infer M> ? M : TReturn), TAsync extends boolean = (TReturn extends Promise<any> ? true : false)>(rule: RegleRuleWithParamsDefinition<TValue, TParams, TAsync, TMetadata>, depsArray: [...TParams]): RegleRuleWithParamsDefinition<TValue, TParams, TAsync, TMetadata>;
81
- //#endregion
82
- //#region src/helpers/applyIf.d.ts
83
73
  /**
84
74
  * The applyIf operator is similar to requiredIf, but it can be used with any rule.
85
75
  * It simplifies conditional rule declarations.
@@ -96,8 +86,6 @@ declare function withParams<TValue extends any, TParams extends any[], TReturn e
96
86
  * ```
97
87
  */
98
88
  declare function applyIf<TValue extends any, TParams extends any[], TReturn extends RegleRuleMetadataDefinition | Promise<RegleRuleMetadataDefinition> = RegleRuleMetadataDefinition, TMetadata extends RegleRuleMetadataDefinition = (TReturn extends Promise<infer M> ? M : TReturn), TAsync extends boolean = (TReturn extends Promise<any> ? true : false)>(_condition: MaybeRefOrGetter<Maybe<boolean>>, rule: InlineRuleDeclaration<TValue, TParams, TReturn> | RegleRuleDefinition<TValue, TParams, TAsync, TMetadata>): RegleRuleDefinition<TValue, [...TParams, condition: boolean], TAsync, TMetadata>;
99
- //#endregion
100
- //#region src/helpers/ruleHelpers/isFilled.d.ts
101
89
  /**
102
90
  * This is almost a must have for optional fields. It checks if any value you provided is defined (including arrays and objects). You can base your validator result on this.
103
91
  *
@@ -107,67 +95,24 @@ declare function applyIf<TValue extends any, TParams extends any[], TReturn exte
107
95
  * @param [considerEmptyArrayInvalid=true] - will return true if set to `false`. (default: `true`)
108
96
  */
109
97
  declare function isFilled<T extends unknown>(value: T, considerEmptyArrayInvalid?: boolean): value is NonNullable<T>;
110
- //#endregion
111
- //#region src/helpers/ruleHelpers/isNumber.d.ts
112
98
  /**
113
99
  * This is a type guard that will check if the passed value is a real Number. This also returns false for NaN, so this is better than typeof value === "number".
114
100
  */
115
101
  declare function isNumber(value: unknown): value is number;
116
- //#endregion
117
- //#region src/helpers/ruleHelpers/matchRegex.d.ts
118
102
  /**
119
103
  * This utility can take multiple regular expressions as arguments. It checks the input's validity and tests it against the provided regex patterns.
120
104
  */
121
105
  declare function matchRegex(_value: string | number | null | undefined, ...expr: RegExp[]): boolean;
122
- //#endregion
123
- //#region src/helpers/ruleHelpers/getSize.d.ts
124
106
  /**
125
107
  * This helper will return the length of any data type you pass. It works with strings, arrays, objects and numbers.
126
108
  */
127
109
  declare function getSize(value: MaybeRef<string | any[] | Record<string, any> | number>): number;
128
- //#endregion
129
- //#region src/helpers/ruleHelpers/toNumber.d.ts
130
110
  /**
131
111
  * This utility converts any string (or number) into a number using the Number constructor.
132
112
  *
133
113
  * @returns ⚠️ Warning, returned value can be NaN
134
114
  */
135
115
  declare function toNumber<T extends number | string | undefined>(argument: T): number;
136
- //#endregion
137
- //#region ../../node_modules/.pnpm/type-fest@5.2.0/node_modules/type-fest/source/empty-object.d.ts
138
- declare const emptyObjectSymbol: unique symbol;
139
-
140
- /**
141
- Represents a strictly empty plain object, the `{}` value.
142
-
143
- When you annotate something as the type `{}`, it can be anything except `null` and `undefined`. This means that you cannot use `{}` to represent an empty plain object ([read more](https://stackoverflow.com/questions/47339869/typescript-empty-object-and-any-difference/52193484#52193484)).
144
-
145
- @example
146
- ```
147
- import type {EmptyObject} from 'type-fest';
148
-
149
- // The following illustrates the problem with `{}`.
150
- const foo1: {} = {}; // Pass
151
- const foo2: {} = []; // Pass
152
- const foo3: {} = 42; // Pass
153
- const foo4: {} = {a: 1}; // Pass
154
-
155
- // With `EmptyObject` only the first case is valid.
156
- const bar1: EmptyObject = {}; // Pass
157
- const bar2: EmptyObject = 42; // Fail
158
- const bar3: EmptyObject = []; // Fail
159
- const bar4: EmptyObject = {a: 1}; // Fail
160
- ```
161
-
162
- Unfortunately, `Record<string, never>`, `Record<keyof any, never>` and `Record<never, never>` do not work. See {@link https://github.com/sindresorhus/type-fest/issues/395 #395}.
163
-
164
- @category Object
165
- */
166
- type EmptyObject = {
167
- [emptyObjectSymbol]?: never;
168
- };
169
- //#endregion
170
- //#region ../shared/utils/isEmpty.d.ts
171
116
  /**
172
117
  * This is the inverse of isFilled. It will check if the value is in any way empty (including arrays and objects)
173
118
  *
@@ -177,20 +122,14 @@ type EmptyObject = {
177
122
  * @param [considerEmptyArrayInvalid=true] - will return false if set to `false`. (default: `true`)
178
123
  */
179
124
  declare function isEmpty(value: unknown, considerEmptyArrayInvalid?: boolean): value is null | undefined | [] | EmptyObject;
180
- //#endregion
181
- //#region ../shared/utils/isDate.d.ts
182
125
  /**
183
126
  * This is a useful helper that can check if the provided value is a Date, it is used internally for date rules. This can also check strings.
184
127
  */
185
128
  declare function isDate(value: unknown): value is Date | string;
186
- //#endregion
187
- //#region ../shared/utils/toDate.d.ts
188
129
  /**
189
130
  * This utility will coerce any string, number or Date value into a Date using the Date constructor.
190
131
  */
191
132
  declare function toDate(argument: Maybe<Date | number | string>): Date;
192
- //#endregion
193
- //#region src/types/utils/params.utils.d.ts
194
133
  type ExtractValueFromRules<T extends any[]> = T extends [infer F, ...infer R] ? F extends RegleRuleDefinition<infer V, any, any, any> ? [V, ...ExtractValueFromRules<R>] : F extends InlineRuleDeclaration<infer V, any> ? [V, ...ExtractValueFromRules<R>] : [F, ...ExtractValueFromRules<R>] : [];
195
134
  type ExtractAsyncStatesFromRules<T extends any[]> = T extends [infer F, ...infer R] ? F extends RegleRuleDefinition<any, any, infer A, any> ? [A, ...ExtractValueFromRules<R>] : F extends InlineRuleDeclaration<any, any> ? [ReturnType<F> extends Promise<any> ? true : false, ...ExtractValueFromRules<R>] : [F, ...ExtractValueFromRules<R>] : [];
196
135
  type ExtractAsync<T extends [...any[]]> = T extends [infer F, ...infer R] ? F extends true ? true : F extends false ? ExtractAsync<R> : false : false;
@@ -205,26 +144,18 @@ type ExtractMetadata<T extends [...any[]]> = T extends [infer F, ...infer R] ? F
205
144
  type GuessMetadataFromRules<T extends any[], TMeta = ExtractMetadata<ExtractMetaDataFromRules<T>>> = TMeta extends EmptyObject ? boolean : TMeta;
206
145
  type FilterTuple<T extends any[]> = T extends [infer F, ...infer R] ? [F] extends [[]] ? [...FilterTuple<R>] : [F, ...FilterTuple<R>] : [];
207
146
  type UnwrapTuples<T extends any[]> = FilterTuple<T> extends [infer U extends any[]] ? U : FilterTuple<T>;
208
- //#endregion
209
- //#region src/helpers/and.d.ts
210
147
  /**
211
148
  * The and operator combines multiple rules and validates successfully only if all provided rules are valid.
212
149
  */
213
150
  declare function and<const TRules extends [FormRuleDeclaration<any, any>, ...FormRuleDeclaration<any, any>[]]>(...rules: [...TRules]): RegleRuleDefinition<ExtractValueFromRules<TRules>[number], UnwrapTuples<ExtractParamsFromRules<TRules>>, GuessAsyncFromRules<TRules>, GuessMetadataFromRules<TRules>>;
214
- //#endregion
215
- //#region src/helpers/or.d.ts
216
151
  /**
217
152
  * The or operator validates successfully if at least one of the provided rules is valid.
218
153
  */
219
154
  declare function or<TRules extends [FormRuleDeclaration<any, any>, ...FormRuleDeclaration<any, any>[]]>(...rules: [...TRules]): RegleRuleDefinition<ExtractValueFromRules<TRules>[number], UnwrapTuples<ExtractParamsFromRules<TRules>>, GuessAsyncFromRules<TRules>, GuessMetadataFromRules<TRules>>;
220
- //#endregion
221
- //#region src/helpers/not.d.ts
222
155
  /**
223
156
  * The not operator passes when the provided rule fails and fails when the rule passes. It can be combined with other rules.
224
157
  */
225
158
  declare function not<TValue, TParams extends any[] = [], TReturn extends RegleRuleMetadataDefinition | Promise<RegleRuleMetadataDefinition> = RegleRuleMetadataDefinition, TMetadata extends RegleRuleMetadataDefinition = (TReturn extends Promise<infer M> ? M : TReturn), TAsync extends boolean = (TReturn extends Promise<any> ? true : false)>(rule: RegleRuleDefinition<TValue, TParams, TAsync, TMetadata> | InlineRuleDeclaration<TValue, TParams, TReturn>, message?: RegleRuleDefinitionWithMetadataProcessor<TValue, RegleRuleMetadataConsumer<TValue, TParams, TMetadata>, string | string[]>): RegleRuleDefinition<TValue, TParams, TAsync, TMetadata>;
226
- //#endregion
227
- //#region src/helpers/assignIf.d.ts
228
159
  /**
229
160
  * The assignIf is a shorthand for conditional destructuring assignment.
230
161
  * It allows to apply multiple rules to a field conditionally.
@@ -240,24 +171,18 @@ declare function not<TValue, TParams extends any[] = [], TReturn extends RegleRu
240
171
  * ```
241
172
  */
242
173
  declare function assignIf<TValue extends unknown = any, TCustomRules extends Partial<AllRulesDeclarations> = Partial<AllRulesDeclarations>, TRulesDelc extends RegleRuleDecl<TValue, TCustomRules> = RegleRuleDecl<TValue, TCustomRules>>(_condition: MaybeRefOrGetter<Maybe<boolean>>, rules: TRulesDelc): ComputedRef<TRulesDelc>;
243
- //#endregion
244
- //#region src/rules/alpha.d.ts
245
174
  /**
246
175
  * Allows only alphabetic characters.
247
176
  *
248
177
  * @param [options] - Alpha rules options
249
178
  * */
250
179
  declare const alpha: RegleRuleWithParamsDefinition<string, [options?: CommonAlphaOptions | undefined], false, boolean, MaybeInput<string>, string>;
251
- //#endregion
252
- //#region src/rules/alphaNum.d.ts
253
180
  /**
254
181
  * Allows only alphanumeric characters.
255
182
  *
256
183
  * @param [options] - Alpha rules options
257
184
  */
258
185
  declare const alphaNum: RegleRuleWithParamsDefinition<string | number, [options?: CommonAlphaOptions | undefined], false, boolean, MaybeInput<string>>;
259
- //#endregion
260
- //#region src/rules/between.d.ts
261
186
  /**
262
187
  * Checks if a number is in specified bounds. min and max are both inclusive.
263
188
  *
@@ -265,38 +190,28 @@ declare const alphaNum: RegleRuleWithParamsDefinition<string | number, [options?
265
190
  * @param max - the maximum limit
266
191
  */
267
192
  declare const between: RegleRuleWithParamsDefinition<number, [min: number, max: number, options?: CommonComparisonOptions], false, boolean, MaybeInput<number>>;
268
- //#endregion
269
- //#region src/rules/boolean.d.ts
270
193
  /**
271
194
  * Requires a value to be a native boolean type
272
195
  *
273
196
  * Mainly used for typing
274
197
  */
275
198
  declare const boolean: RegleRuleDefinition<unknown, [], false, boolean, MaybeInput<boolean>, unknown>;
276
- //#endregion
277
- //#region src/rules/checked.d.ts
278
199
  /**
279
200
  * Requires a boolean value to be true. This is useful for checkbox inputs.
280
201
  */
281
202
  declare const checked: RegleRuleDefinition<boolean, [], false, boolean, MaybeInput<boolean>>;
282
- //#endregion
283
- //#region src/rules/contains.d.ts
284
203
  /**
285
204
  * Checks if the string contains the specified substring.
286
205
  *
287
206
  * @param part - the part the value needs to contain
288
207
  */
289
208
  declare const contains: RegleRuleWithParamsDefinition<string, [part: MaybeInput<string>], false, boolean, MaybeInput<string>>;
290
- //#endregion
291
- //#region src/rules/date.d.ts
292
209
  /**
293
210
  * Requires a value to be a native Date constructor
294
211
  *
295
212
  * Mainly used for typing
296
213
  */
297
214
  declare const date: RegleRuleDefinition<unknown, [], false, boolean, MaybeInput<Date>, unknown>;
298
- //#endregion
299
- //#region src/rules/dateAfter.d.ts
300
215
  /**
301
216
  * Checks if the date is after the given parameter.
302
217
  *
@@ -310,8 +225,6 @@ declare const dateAfter: RegleRuleWithParamsDefinition<string | Date, [after: Ma
310
225
  $valid: false;
311
226
  error: 'value-or-parameter-not-a-date';
312
227
  }, MaybeInput<string | Date>>;
313
- //#endregion
314
- //#region src/rules/dateBefore.d.ts
315
228
  /**
316
229
  * Checks if the date is before the given parameter.
317
230
  *
@@ -325,8 +238,6 @@ declare const dateBefore: RegleRuleWithParamsDefinition<string | Date, [before:
325
238
  $valid: false;
326
239
  error: 'value-or-parameter-not-a-date';
327
240
  }, MaybeInput<string | Date>>;
328
- //#endregion
329
- //#region src/rules/dateBetween.d.ts
330
241
  /**
331
242
  * Checks if the date falls between the specified bounds.
332
243
  *
@@ -335,74 +246,52 @@ declare const dateBefore: RegleRuleWithParamsDefinition<string | Date, [before:
335
246
  * @param options - comparison options
336
247
  */
337
248
  declare const dateBetween: RegleRuleWithParamsDefinition<string | Date, [before: MaybeInput<string | Date>, after: MaybeInput<string | Date>, options?: CommonComparisonOptions], false, boolean, MaybeInput<string | Date>>;
338
- //#endregion
339
- //#region src/rules/decimal.d.ts
340
249
  /**
341
250
  * Allows positive and negative decimal numbers.
342
251
  */
343
252
  declare const decimal: RegleRuleDefinition<string | number, [], false, boolean, MaybeInput<number | undefined>>;
344
- //#endregion
345
- //#region src/rules/email.d.ts
346
253
  /**
347
254
  * Validates email addresses. Always verify on the server to ensure the address is real and not already in use.
348
255
  */
349
256
  declare const email: RegleRuleDefinition<string, [], false, boolean, MaybeInput<string>>;
350
- //#endregion
351
- //#region src/rules/endsWith.d.ts
352
257
  /**
353
258
  * Checks if the string ends with the specified substring.
354
259
  *
355
260
  * @param part - the value the field must end with
356
261
  */
357
262
  declare const endsWith: RegleRuleWithParamsDefinition<string, [part: MaybeInput<string>], false, boolean, MaybeInput<string>>;
358
- //#endregion
359
- //#region src/rules/exactLength.d.ts
360
263
  /**
361
264
  * Requires the input value to have a strict specified length, inclusive. Works with arrays, objects and strings.
362
265
  *
363
266
  * @param count - the required length
364
267
  */
365
268
  declare const exactLength: RegleRuleWithParamsDefinition<string | any[] | Record<PropertyKey, any>, [count: number], false, boolean>;
366
- //#endregion
367
- //#region src/rules/exactValue.d.ts
368
269
  /**
369
270
  * Requires a field to have a strict numeric value.
370
271
  */
371
272
  declare const exactValue: RegleRuleWithParamsDefinition<number, [count: number], false, boolean, MaybeInput<number>>;
372
- //#endregion
373
- //#region src/rules/hexadecimal.d.ts
374
273
  /**
375
274
  * Allows only hexadecimal values.
376
275
  */
377
276
  declare const hexadecimal: RegleRuleDefinition<string, [], false, boolean, MaybeInput<string>>;
378
- //#endregion
379
- //#region src/rules/integer.d.ts
380
277
  /**
381
278
  * Allows only integers (positive and negative).
382
279
  */
383
280
  declare const integer: RegleRuleDefinition<string | number, [], false, boolean, MaybeInput<number>>;
384
- //#endregion
385
- //#region src/rules/ipv4Address.d.ts
386
281
  /**
387
282
  * Validates IPv4 addresses in dotted decimal notation 127.0.0.1.
388
283
  */
389
284
  declare const ipv4Address: RegleRuleDefinition<string, [], false, boolean, MaybeInput<string>>;
390
- //#endregion
391
- //#region src/rules/literal.d.ts
392
285
  /**
393
286
  * Allow only one possible literal value
394
287
  */
395
288
  declare function literal<const TValue extends string | number>(literal: MaybeRefOrGetter<TValue>): RegleRuleDefinition<TValue, [literal: TValue], false, boolean, MaybeInput<TValue>, string | number>;
396
- //#endregion
397
- //#region src/rules/macAddress.d.ts
398
289
  /**
399
290
  * Validates MAC addresses. Call as a function to specify a custom separator (e.g., ':' or an empty string for 00ff1122334455).
400
291
  *
401
292
  * @param separator - the custom separator
402
293
  */
403
294
  declare const macAddress: RegleRuleWithParamsDefinition<string, [separator?: string | undefined], false, boolean, MaybeInput<string>>;
404
- //#endregion
405
- //#region src/rules/maxLength.d.ts
406
295
  /**
407
296
  * Requires the input value to have a maximum specified length, inclusive. Works with arrays, objects and strings.
408
297
  *
@@ -410,8 +299,6 @@ declare const macAddress: RegleRuleWithParamsDefinition<string, [separator?: str
410
299
  * @param options - comparison options
411
300
  */
412
301
  declare const maxLength: RegleRuleWithParamsDefinition<string | any[] | Record<PropertyKey, any>, [count: number, options?: CommonComparisonOptions], false, boolean>;
413
- //#endregion
414
- //#region src/rules/maxValue.d.ts
415
302
  /**
416
303
  * Requires a field to have a specified maximum numeric value.
417
304
  *
@@ -419,8 +306,6 @@ declare const maxLength: RegleRuleWithParamsDefinition<string | any[] | Record<P
419
306
  * @param options - comparison options
420
307
  */
421
308
  declare const maxValue: RegleRuleWithParamsDefinition<number | string, [count: number | string, options?: CommonComparisonOptions], false, boolean, MaybeInput<number | string>>;
422
- //#endregion
423
- //#region src/rules/minLength.d.ts
424
309
  /**
425
310
  * Requires the input value to have a minimum specified length, inclusive. Works with arrays, objects and strings.
426
311
  *
@@ -428,8 +313,6 @@ declare const maxValue: RegleRuleWithParamsDefinition<number | string, [count: n
428
313
  * @param options - comparison options
429
314
  */
430
315
  declare const minLength: RegleRuleWithParamsDefinition<string | any[] | Record<PropertyKey, any>, [count: number, options?: CommonComparisonOptions], false, boolean>;
431
- //#endregion
432
- //#region src/rules/minValue.d.ts
433
316
  /**
434
317
  * Requires a field to have a specified minimum numeric value.
435
318
  *
@@ -437,8 +320,6 @@ declare const minLength: RegleRuleWithParamsDefinition<string | any[] | Record<P
437
320
  * @param options - comparison options
438
321
  */
439
322
  declare const minValue: RegleRuleWithParamsDefinition<number | string, [count: number | string, options?: CommonComparisonOptions], false, boolean, MaybeInput<number | string>>;
440
- //#endregion
441
- //#region src/rules/nativeEnum.d.ts
442
323
  type EnumLike = {
443
324
  [k: string]: string | number;
444
325
  [nu: number]: string;
@@ -447,22 +328,16 @@ type EnumLike = {
447
328
  * Validate against a native Typescript enum value.
448
329
  */
449
330
  declare function nativeEnum<T extends EnumLike>(enumLike: T): RegleRuleDefinition<MaybeInput<T[keyof T]>, [enumLike: T], false, boolean, MaybeInput<T[keyof T]>, string | number>;
450
- //#endregion
451
- //#region src/rules/number.d.ts
452
331
  /**
453
332
  * Requires a value to be a native number type
454
333
  *
455
334
  * Mainly used for typing
456
335
  */
457
336
  declare const number: RegleRuleDefinition<unknown, [], false, boolean, MaybeInput<number>, unknown>;
458
- //#endregion
459
- //#region src/rules/numeric.d.ts
460
337
  /**
461
338
  * Allows only numeric values (including numeric strings).
462
339
  */
463
340
  declare const numeric: RegleRuleDefinition<string | number, [], false, boolean, MaybeInput<string | number>>;
464
- //#endregion
465
- //#region src/rules/oneOf.d.ts
466
341
  interface OneOfFn {
467
342
  <const TValues extends NonEmptyTuple<string | number> | NonEmptyTuple<string> | NonEmptyTuple<number>>(options: MaybeReadonly<MaybeRefOrGetter<[...TValues]>>): RegleRuleDefinition<TValues[number], [options: TValues], false, boolean, MaybeInput<TValues[number]>, string | number>;
468
343
  /** Keep this definition without generics for inference */
@@ -472,36 +347,26 @@ interface OneOfFn {
472
347
  * Allow only one of the values from a fixed Array of possible entries.
473
348
  */
474
349
  declare const oneOf: OneOfFn;
475
- //#endregion
476
- //#region src/rules/regex.d.ts
477
350
  /**
478
351
  * Checks if the value matches one or more regular expressions.
479
352
  */
480
353
  declare const regex: RegleRuleWithParamsDefinition<string | number, [regexp: RegExp | RegExp[]], false, boolean, MaybeInput<string | number>>;
481
- //#endregion
482
- //#region src/rules/required.d.ts
483
354
  /**
484
355
  * Requires non-empty data. Checks for empty arrays and strings containing only whitespaces.
485
356
  */
486
357
  declare const required: RegleRuleDefinition<unknown, [], false, boolean, unknown>;
487
- //#endregion
488
- //#region src/rules/requiredIf.d.ts
489
358
  /**
490
359
  * Requires non-empty data, only if provided data property, ref, or a function resolves to true.
491
360
  *
492
361
  * @param condition - the condition to enable the required rule
493
362
  */
494
363
  declare const requiredIf: RegleRuleWithParamsDefinition<unknown, [condition: boolean], false, boolean>;
495
- //#endregion
496
- //#region src/rules/requiredUnless.d.ts
497
364
  /**
498
365
  * Requires non-empty data, only if provided data property, ref, or a function resolves to false.
499
366
  *
500
367
  * @param condition - the condition to disable the required rule
501
368
  */
502
369
  declare const requiredUnless: RegleRuleWithParamsDefinition<unknown, [condition: boolean], false, boolean>;
503
- //#endregion
504
- //#region src/rules/sameAs.d.ts
505
370
  interface SameAsFn {
506
371
  <TTarget extends unknown = unknown>(target: MaybeRefOrGetter<TTarget>, otherName?: MaybeRefOrGetter<string>): RegleRuleDefinition<TTarget, [target: TTarget, otherName?: string], false, boolean, TTarget extends MaybeInput<infer M> ? M : MaybeInput<TTarget>>;
507
372
  /** Keep this definition without generics for inference */
@@ -511,35 +376,26 @@ interface SameAsFn {
511
376
  * Checks if the value matches the specified property or ref.
512
377
  */
513
378
  declare const sameAs: SameAsFn;
514
- //#endregion
515
- //#region src/rules/startsWith.d.ts
516
379
  /**
517
380
  * Checks if the string starts with the specified substring.
518
381
  *
519
382
  * @private part - the value the field must start with
520
383
  */
521
384
  declare const startsWith: RegleRuleWithParamsDefinition<string, [part: MaybeInput<string>], false, boolean, MaybeInput<string>>;
522
- //#endregion
523
- //#region src/rules/string.d.ts
524
385
  /**
525
386
  * Requires a value to be a native string type
526
387
  *
527
388
  * Mainly used for typing
528
389
  */
529
390
  declare const string: RegleRuleDefinition<unknown, [], false, boolean, MaybeInput<string>, unknown>;
530
- //#endregion
531
- //#region src/rules/type.d.ts
532
391
  /**
533
392
  * Define the input type of a rule. No runtime validation.
534
393
  *
535
394
  * Override any input type set by other rules.
536
395
  */
537
396
  declare function type<T>(): RegleRuleDefinition<unknown, [], false, boolean, MaybeInput<T>>;
538
- //#endregion
539
- //#region src/rules/url.d.ts
540
397
  /**
541
398
  * Validates URLs.
542
399
  */
543
400
  declare const url: RegleRuleDefinition<string, [], false, boolean, MaybeInput<string>>;
544
- //#endregion
545
401
  export { EnumLike, alpha, alphaNum, and, applyIf, assignIf, between, boolean, checked, contains, date, dateAfter, dateBefore, dateBetween, decimal, email, endsWith, exactLength, exactValue, getSize, hexadecimal, integer, ipv4Address, isDate, isEmpty, isFilled, isNumber, literal, macAddress, matchRegex, maxLength, maxValue, minLength, minValue, nativeEnum, not, number, numeric, oneOf, or, regex, required, requiredIf, requiredUnless, sameAs, startsWith, string, toDate, toNumber, type, url, withAsync, withMessage, withParams, withTooltip };
@@ -1,7 +1,6 @@
1
1
  import { InternalRuleType, createRule, unwrapRuleParameters } from "@regle/core";
2
2
  import { computed, toValue, unref } from "vue";
3
3
 
4
- //#region src/helpers/withMessage.ts
5
4
  function withMessage(rule, newMessage) {
6
5
  let _type;
7
6
  let validator;
@@ -30,8 +29,6 @@ function withMessage(rule, newMessage) {
30
29
  } else return newRule;
31
30
  }
32
31
 
33
- //#endregion
34
- //#region src/helpers/withTooltip.ts
35
32
  function withTooltip(rule, newTooltip) {
36
33
  let _type;
37
34
  let validator;
@@ -59,8 +56,6 @@ function withTooltip(rule, newTooltip) {
59
56
  } else return newRule;
60
57
  }
61
58
 
62
- //#endregion
63
- //#region src/helpers/withAsync.ts
64
59
  function withAsync(rule, depsArray) {
65
60
  let _type;
66
61
  let validator;
@@ -86,8 +81,6 @@ function withAsync(rule, depsArray) {
86
81
  return newRule(...depsArray ?? []);
87
82
  }
88
83
 
89
- //#endregion
90
- //#region src/helpers/withParams.ts
91
84
  function withParams(rule, depsArray) {
92
85
  let _type;
93
86
  let validator;
@@ -112,8 +105,6 @@ function withParams(rule, depsArray) {
112
105
  return newRule(...depsArray);
113
106
  }
114
107
 
115
- //#endregion
116
- //#region src/helpers/applyIf.ts
117
108
  /**
118
109
  * The applyIf operator is similar to requiredIf, but it can be used with any rule.
119
110
  * It simplifies conditional rule declarations.
@@ -163,8 +154,6 @@ function applyIf(_condition, rule) {
163
154
  else return newRule;
164
155
  }
165
156
 
166
- //#endregion
167
- //#region ../shared/utils/isFile.ts
168
157
  /**
169
158
  * Server side friendly way of checking for a File
170
159
  */
@@ -172,8 +161,6 @@ function isFile(value) {
172
161
  return value?.constructor?.name == "File" || value?.constructor?.name == "FileList";
173
162
  }
174
163
 
175
- //#endregion
176
- //#region ../shared/utils/isEmpty.ts
177
164
  /**
178
165
  * This is the inverse of isFilled. It will check if the value is in any way empty (including arrays and objects)
179
166
  *
@@ -193,12 +180,8 @@ function isEmpty(value, considerEmptyArrayInvalid = true) {
193
180
  return !String(value).length;
194
181
  }
195
182
 
196
- //#endregion
197
- //#region ../shared/utils/symbol.ts
198
183
  const RegleRuleSymbol = Symbol("regle-rule");
199
184
 
200
- //#endregion
201
- //#region ../shared/utils/isDate.ts
202
185
  /**
203
186
  * This is a useful helper that can check if the provided value is a Date, it is used internally for date rules. This can also check strings.
204
187
  */
@@ -218,8 +201,6 @@ function isDate(value) {
218
201
  }
219
202
  }
220
203
 
221
- //#endregion
222
- //#region ../shared/utils/toDate.ts
223
204
  /**
224
205
  * This utility will coerce any string, number or Date value into a Date using the Date constructor.
225
206
  */
@@ -232,8 +213,6 @@ function toDate(argument) {
232
213
  else return /* @__PURE__ */ new Date(NaN);
233
214
  }
234
215
 
235
- //#endregion
236
- //#region src/helpers/ruleHelpers/isFilled.ts
237
216
  /**
238
217
  * This is almost a must have for optional fields. It checks if any value you provided is defined (including arrays and objects). You can base your validator result on this.
239
218
  *
@@ -246,8 +225,6 @@ function isFilled(value, considerEmptyArrayInvalid = true) {
246
225
  return !isEmpty(typeof value === "string" ? value.trim() : value, considerEmptyArrayInvalid);
247
226
  }
248
227
 
249
- //#endregion
250
- //#region src/helpers/ruleHelpers/isNumber.ts
251
228
  /**
252
229
  * This is a type guard that will check if the passed value is a real Number. This also returns false for NaN, so this is better than typeof value === "number".
253
230
  */
@@ -258,8 +235,6 @@ function isNumber(value) {
258
235
  else return true;
259
236
  }
260
237
 
261
- //#endregion
262
- //#region src/helpers/ruleHelpers/matchRegex.ts
263
238
  /**
264
239
  * This utility can take multiple regular expressions as arguments. It checks the input's validity and tests it against the provided regex patterns.
265
240
  */
@@ -272,8 +247,6 @@ function matchRegex(_value, ...expr) {
272
247
  });
273
248
  }
274
249
 
275
- //#endregion
276
- //#region src/helpers/ruleHelpers/getSize.ts
277
250
  /**
278
251
  * This helper will return the length of any data type you pass. It works with strings, arrays, objects and numbers.
279
252
  */
@@ -288,8 +261,6 @@ function getSize(value) {
288
261
  return String(_value).length;
289
262
  }
290
263
 
291
- //#endregion
292
- //#region src/helpers/ruleHelpers/toNumber.ts
293
264
  /**
294
265
  * This utility converts any string (or number) into a number using the Number constructor.
295
266
  *
@@ -307,8 +278,6 @@ function toNumber(argument) {
307
278
  return NaN;
308
279
  }
309
280
 
310
- //#endregion
311
- //#region src/helpers/and.ts
312
281
  /**
313
282
  * The and operator combines multiple rules and validates successfully only if all provided rules are valid.
314
283
  */
@@ -375,8 +344,6 @@ function and(...rules) {
375
344
  else return newRule;
376
345
  }
377
346
 
378
- //#endregion
379
- //#region src/helpers/or.ts
380
347
  /**
381
348
  * The or operator validates successfully if at least one of the provided rules is valid.
382
349
  */
@@ -434,8 +401,6 @@ function or(...rules) {
434
401
  else return newRule;
435
402
  }
436
403
 
437
- //#endregion
438
- //#region src/helpers/not.ts
439
404
  /**
440
405
  * The not operator passes when the provided rule fails and fails when the rule passes. It can be combined with other rules.
441
406
  */
@@ -471,8 +436,6 @@ function not(rule, message) {
471
436
  else return newRule;
472
437
  }
473
438
 
474
- //#endregion
475
- //#region src/helpers/assignIf.ts
476
439
  /**
477
440
  * The assignIf is a shorthand for conditional destructuring assignment.
478
441
  * It allows to apply multiple rules to a field conditionally.
@@ -494,8 +457,6 @@ function assignIf(_condition, rules) {
494
457
  });
495
458
  }
496
459
 
497
- //#endregion
498
- //#region src/rules/alpha.ts
499
460
  const alphaRegex = /^[a-zA-Z]*$/;
500
461
  const alphaSymbolRegex = /^[\w.]+$/;
501
462
  /**
@@ -513,8 +474,6 @@ const alpha = createRule({
513
474
  message: "The value is not alphabetical"
514
475
  });
515
476
 
516
- //#endregion
517
- //#region src/rules/alphaNum.ts
518
477
  const alphaNumRegex = /^[a-zA-Z0-9]*$/;
519
478
  const alphaNumSymbolRegex = /^[a-zA-Z0-9_]*$/;
520
479
  /**
@@ -532,8 +491,6 @@ const alphaNum = createRule({
532
491
  message: "The value must be alpha-numeric"
533
492
  });
534
493
 
535
- //#endregion
536
- //#region src/rules/between.ts
537
494
  /**
538
495
  * Checks if a number is in specified bounds. min and max are both inclusive.
539
496
  *
@@ -560,8 +517,6 @@ const between = createRule({
560
517
  }
561
518
  });
562
519
 
563
- //#endregion
564
- //#region src/rules/boolean.ts
565
520
  /**
566
521
  * Requires a value to be a native boolean type
567
522
  *
@@ -576,8 +531,6 @@ const boolean = createRule({
576
531
  message: "The value must be a native boolean"
577
532
  });
578
533
 
579
- //#endregion
580
- //#region src/rules/checked.ts
581
534
  /**
582
535
  * Requires a boolean value to be true. This is useful for checkbox inputs.
583
536
  */
@@ -590,8 +543,6 @@ const checked = createRule({
590
543
  message: "The field must be checked"
591
544
  });
592
545
 
593
- //#endregion
594
- //#region src/rules/contains.ts
595
546
  /**
596
547
  * Checks if the string contains the specified substring.
597
548
  *
@@ -608,8 +559,6 @@ const contains = createRule({
608
559
  }
609
560
  });
610
561
 
611
- //#endregion
612
- //#region src/rules/date.ts
613
562
  /**
614
563
  * Requires a value to be a native Date constructor
615
564
  *
@@ -624,8 +573,6 @@ const date = createRule({
624
573
  message: "The value must be a native Date constructor"
625
574
  });
626
575
 
627
- //#endregion
628
- //#region src/utils/getLocale.util.ts
629
576
  function getUserLocale() {
630
577
  if (navigator.languages != void 0) return navigator.languages[0];
631
578
  return navigator.language;
@@ -635,8 +582,6 @@ function formatLocaleDate(date$1) {
635
582
  return "?";
636
583
  }
637
584
 
638
- //#endregion
639
- //#region src/rules/dateAfter.ts
640
585
  /**
641
586
  * Checks if the date is after the given parameter.
642
587
  *
@@ -668,8 +613,6 @@ const dateAfter = createRule({
668
613
  }
669
614
  });
670
615
 
671
- //#endregion
672
- //#region src/rules/dateBefore.ts
673
616
  /**
674
617
  * Checks if the date is before the given parameter.
675
618
  *
@@ -701,8 +644,6 @@ const dateBefore = createRule({
701
644
  }
702
645
  });
703
646
 
704
- //#endregion
705
- //#region src/rules/dateBetween.ts
706
647
  /**
707
648
  * Checks if the date falls between the specified bounds.
708
649
  *
@@ -723,8 +664,6 @@ const dateBetween = createRule({
723
664
  }
724
665
  });
725
666
 
726
- //#endregion
727
- //#region src/rules/decimal.ts
728
667
  const decimalRegex = /^[-]?\d*(\.\d+)?$/;
729
668
  /**
730
669
  * Allows positive and negative decimal numbers.
@@ -738,8 +677,6 @@ const decimal = createRule({
738
677
  message: "The value must be decimal"
739
678
  });
740
679
 
741
- //#endregion
742
- //#region src/rules/email.ts
743
680
  const emailRegex = /^(?:[A-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[A-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9]{2,}(?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/i;
744
681
  /**
745
682
  * Validates email addresses. Always verify on the server to ensure the address is real and not already in use.
@@ -753,8 +690,6 @@ const email = createRule({
753
690
  message: "The value must be an valid email address"
754
691
  });
755
692
 
756
- //#endregion
757
- //#region src/rules/endsWith.ts
758
693
  /**
759
694
  * Checks if the string ends with the specified substring.
760
695
  *
@@ -771,8 +706,6 @@ const endsWith = createRule({
771
706
  }
772
707
  });
773
708
 
774
- //#endregion
775
- //#region src/rules/exactLength.ts
776
709
  /**
777
710
  * Requires the input value to have a strict specified length, inclusive. Works with arrays, objects and strings.
778
711
  *
@@ -793,8 +726,6 @@ const exactLength = createRule({
793
726
  }
794
727
  });
795
728
 
796
- //#endregion
797
- //#region src/rules/exactValue.ts
798
729
  /**
799
730
  * Requires a field to have a strict numeric value.
800
731
  */
@@ -813,8 +744,6 @@ const exactValue = createRule({
813
744
  }
814
745
  });
815
746
 
816
- //#endregion
817
- //#region src/rules/hexadecimal.ts
818
747
  const hexadecimalRegex = /^[a-fA-F0-9]*$/;
819
748
  /**
820
749
  * Allows only hexadecimal values.
@@ -828,8 +757,6 @@ const hexadecimal = createRule({
828
757
  message: "The value must be hexadecimal"
829
758
  });
830
759
 
831
- //#endregion
832
- //#region src/rules/integer.ts
833
760
  const integerRegex = /(^[0-9]*$)|(^-[0-9]+$)/;
834
761
  /**
835
762
  * Allows only integers (positive and negative).
@@ -843,8 +770,6 @@ const integer = createRule({
843
770
  message: "The value must be an integer"
844
771
  });
845
772
 
846
- //#endregion
847
- //#region src/rules/ipv4Address.ts
848
773
  function nibbleValid(nibble) {
849
774
  if (nibble.length > 3 || nibble.length === 0) return false;
850
775
  if (nibble[0] === "0" && nibble !== "0") return false;
@@ -866,8 +791,6 @@ const ipv4Address = createRule({
866
791
  message: "The value is not a valid IPv4 address"
867
792
  });
868
793
 
869
- //#endregion
870
- //#region src/rules/literal.ts
871
794
  /**
872
795
  * Allow only one possible literal value
873
796
  */
@@ -878,8 +801,6 @@ function literal(literal$1) {
878
801
  }, [computed(() => toValue(literal$1))]), ({ $params: [literal$2] }) => `Value should be ${literal$2}.`);
879
802
  }
880
803
 
881
- //#endregion
882
- //#region src/rules/macAddress.ts
883
804
  /**
884
805
  * Validates MAC addresses. Call as a function to specify a custom separator (e.g., ':' or an empty string for 00ff1122334455).
885
806
  *
@@ -897,8 +818,6 @@ const macAddress = createRule({
897
818
  });
898
819
  const hexValid = (hex) => hex.toLowerCase().match(/^[0-9a-f]{2}$/);
899
820
 
900
- //#endregion
901
- //#region src/rules/maxLength.ts
902
821
  /**
903
822
  * Requires the input value to have a maximum specified length, inclusive. Works with arrays, objects and strings.
904
823
  *
@@ -923,8 +842,6 @@ const maxLength = createRule({
923
842
  }
924
843
  });
925
844
 
926
- //#endregion
927
- //#region src/rules/maxValue.ts
928
845
  /**
929
846
  * Requires a field to have a specified maximum numeric value.
930
847
  *
@@ -950,8 +867,6 @@ const maxValue = createRule({
950
867
  }
951
868
  });
952
869
 
953
- //#endregion
954
- //#region src/rules/minLength.ts
955
870
  /**
956
871
  * Requires the input value to have a minimum specified length, inclusive. Works with arrays, objects and strings.
957
872
  *
@@ -976,8 +891,6 @@ const minLength = createRule({
976
891
  }
977
892
  });
978
893
 
979
- //#endregion
980
- //#region src/rules/minValue.ts
981
894
  /**
982
895
  * Requires a field to have a specified minimum numeric value.
983
896
  *
@@ -1003,8 +916,6 @@ const minValue = createRule({
1003
916
  }
1004
917
  });
1005
918
 
1006
- //#endregion
1007
- //#region src/rules/nativeEnum.ts
1008
919
  function getValidEnumValues(obj) {
1009
920
  const validKeys = Object.keys(obj).filter((k) => typeof obj[obj[k]] !== "number");
1010
921
  const filtered = {};
@@ -1021,8 +932,6 @@ function nativeEnum(enumLike) {
1021
932
  }, [computed(() => toValue(enumLike))]), ({ $params: [enumLike$1] }) => `The value should be one of those options: ${Object.values(enumLike$1).join(", ")}.`);
1022
933
  }
1023
934
 
1024
- //#endregion
1025
- //#region src/rules/number.ts
1026
935
  /**
1027
936
  * Requires a value to be a native number type
1028
937
  *
@@ -1037,8 +946,6 @@ const number = createRule({
1037
946
  message: "The value must be a native number"
1038
947
  });
1039
948
 
1040
- //#endregion
1041
- //#region src/rules/numeric.ts
1042
949
  const numericRegex = /^\d*(\.\d+)?$/;
1043
950
  /**
1044
951
  * Allows only numeric values (including numeric strings).
@@ -1052,8 +959,6 @@ const numeric = createRule({
1052
959
  message: "The value must be numeric"
1053
960
  });
1054
961
 
1055
- //#endregion
1056
- //#region src/rules/oneOf.ts
1057
962
  /**
1058
963
  * Allow only one of the values from a fixed Array of possible entries.
1059
964
  */
@@ -1066,8 +971,6 @@ const oneOf = createRule({
1066
971
  message: ({ $params: [options] }) => `The value should be one of those options: ${options.join(", ")}.`
1067
972
  });
1068
973
 
1069
- //#endregion
1070
- //#region src/rules/regex.ts
1071
974
  /**
1072
975
  * Checks if the value matches one or more regular expressions.
1073
976
  */
@@ -1080,8 +983,6 @@ const regex = createRule({
1080
983
  message: "The value does not match the required pattern"
1081
984
  });
1082
985
 
1083
- //#endregion
1084
- //#region src/rules/required.ts
1085
986
  /**
1086
987
  * Requires non-empty data. Checks for empty arrays and strings containing only whitespaces.
1087
988
  */
@@ -1093,8 +994,6 @@ const required = createRule({
1093
994
  message: "This field is required"
1094
995
  });
1095
996
 
1096
- //#endregion
1097
- //#region src/rules/requiredIf.ts
1098
997
  /**
1099
998
  * Requires non-empty data, only if provided data property, ref, or a function resolves to true.
1100
999
  *
@@ -1112,8 +1011,6 @@ const requiredIf = createRule({
1112
1011
  }
1113
1012
  });
1114
1013
 
1115
- //#endregion
1116
- //#region src/rules/requiredUnless.ts
1117
1014
  /**
1118
1015
  * Requires non-empty data, only if provided data property, ref, or a function resolves to false.
1119
1016
  *
@@ -1131,8 +1028,6 @@ const requiredUnless = createRule({
1131
1028
  }
1132
1029
  });
1133
1030
 
1134
- //#endregion
1135
- //#region src/rules/sameAs.ts
1136
1031
  /**
1137
1032
  * Checks if the value matches the specified property or ref.
1138
1033
  */
@@ -1147,8 +1042,6 @@ const sameAs = createRule({
1147
1042
  }
1148
1043
  });
1149
1044
 
1150
- //#endregion
1151
- //#region src/rules/startsWith.ts
1152
1045
  /**
1153
1046
  * Checks if the string starts with the specified substring.
1154
1047
  *
@@ -1165,8 +1058,6 @@ const startsWith = createRule({
1165
1058
  }
1166
1059
  });
1167
1060
 
1168
- //#endregion
1169
- //#region src/rules/string.ts
1170
1061
  /**
1171
1062
  * Requires a value to be a native string type
1172
1063
  *
@@ -1181,8 +1072,6 @@ const string = createRule({
1181
1072
  message: "The value must be a string"
1182
1073
  });
1183
1074
 
1184
- //#endregion
1185
- //#region src/rules/type.ts
1186
1075
  /**
1187
1076
  * Define the input type of a rule. No runtime validation.
1188
1077
  *
@@ -1192,8 +1081,6 @@ function type() {
1192
1081
  return (() => true);
1193
1082
  }
1194
1083
 
1195
- //#endregion
1196
- //#region src/rules/url.ts
1197
1084
  /**
1198
1085
  * Regex taken from {@link https://gist.github.com/dperini/729294}
1199
1086
  */
@@ -1210,5 +1097,4 @@ const url = createRule({
1210
1097
  message: "The value is not a valid URL address"
1211
1098
  });
1212
1099
 
1213
- //#endregion
1214
1100
  export { alpha, alphaNum, and, applyIf, assignIf, between, boolean, checked, contains, date, dateAfter, dateBefore, dateBetween, decimal, email, endsWith, exactLength, exactValue, getSize, hexadecimal, integer, ipv4Address, isDate, isEmpty, isFilled, isNumber, literal, macAddress, matchRegex, maxLength, maxValue, minLength, minValue, nativeEnum, not, number, numeric, oneOf, or, regex, required, requiredIf, requiredUnless, sameAs, startsWith, string, toDate, toNumber, type, url, withAsync, withMessage, withParams, withTooltip };
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@regle/rules",
3
- "version": "1.10.1",
3
+ "version": "1.11.0-beta.2",
4
4
  "description": "Collection of rules and helpers for Regle",
5
5
  "dependencies": {
6
- "@regle/core": "1.10.1"
6
+ "@regle/core": "1.11.0-beta.2"
7
7
  },
8
8
  "devDependencies": {
9
9
  "@types/node": "22.19.0",
@@ -13,7 +13,7 @@
13
13
  "tsdown": "0.16.1",
14
14
  "type-fest": "5.2.0",
15
15
  "typescript": "5.9.3",
16
- "vitest": "4.0.6",
16
+ "vitest": "4.0.13",
17
17
  "vue": "3.5.22",
18
18
  "vue-tsc": "3.1.3"
19
19
  },
@@ -21,14 +21,9 @@
21
21
  "exports": {
22
22
  ".": {
23
23
  "types": "./dist/regle-rules.d.ts",
24
- "node": {
25
- "import": {
26
- "production": "./dist/regle-rules.min.js",
27
- "development": "./dist/regle-rules.js",
28
- "default": "./dist/regle-rules.js"
29
- }
30
- },
31
- "import": "./dist/regle-rules.js"
24
+ "production": "./dist/regle-rules.min.js",
25
+ "development": "./dist/regle-rules.js",
26
+ "default": "./dist/regle-rules.js"
32
27
  },
33
28
  "./package.json": "./package.json",
34
29
  "./dist/*": "./dist/*"