kanun 1.0.12 → 1.0.13

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/index.cjs CHANGED
@@ -2271,7 +2271,8 @@ var BaseValidator = class BaseValidator {
2271
2271
  this.messages = new ErrorBag();
2272
2272
  }
2273
2273
  static use(plugin) {
2274
- usePlugin(plugin);
2274
+ if (Array.isArray(plugin)) for (const p of plugin) usePlugin(p);
2275
+ else usePlugin(plugin);
2275
2276
  return this;
2276
2277
  }
2277
2278
  static useContext(context = {}) {
@@ -3252,7 +3253,8 @@ var Validator = class Validator {
3252
3253
  * @returns The Validator class for chaining
3253
3254
  */
3254
3255
  static use(plugin) {
3255
- usePlugin(plugin);
3256
+ if (Array.isArray(plugin)) for (const p of plugin) usePlugin(p);
3257
+ else usePlugin(plugin);
3256
3258
  return this;
3257
3259
  }
3258
3260
  /**
package/dist/index.d.ts CHANGED
@@ -452,9 +452,9 @@ declare class BaseValidator<D extends GenericObject = GenericObject> {
452
452
  */
453
453
  private context;
454
454
  constructor(data: D, rules: InitialRules<D>, customMessages?: CustomMessages<D>, customAttributes?: CustomAttributes<D>);
455
- static use(plugin: ValidatorPlugin): typeof BaseValidator;
455
+ static use(plugin: ValidatorPlugin | ValidatorPlugin[]): typeof BaseValidator;
456
456
  static useContext(context?: GenericObject): typeof BaseValidator;
457
- use(plugin: ValidatorPlugin): this;
457
+ use(plugin: ValidatorPlugin | ValidatorPlugin[]): this;
458
458
  setData<ND extends GenericObject>(data: ND): BaseValidator<ND>;
459
459
  setRules(rules: InitialRules<D>): this;
460
460
  setLang(lang: string): this;
@@ -805,7 +805,7 @@ declare class IValidator<D extends Record<string, any> = any, R extends RulesFor
805
805
  */
806
806
  static make<D extends Record<string, any>, R extends RulesForData<D>>(data: D, rules: R, messages: Partial<Record<MessagesForRules<R>, string>>): IValidator<D, R>;
807
807
  static useDatabase(driver: IDatabaseDriver): typeof IValidator;
808
- static use(plugin: ValidatorPlugin): typeof IValidator;
808
+ static use(plugin: ValidatorPlugin | ValidatorPlugin[]): typeof IValidator;
809
809
  static useContext(context: Record<string, any>): typeof IValidator;
810
810
  /**
811
811
  * Run the validator and store results.
@@ -831,7 +831,7 @@ declare class IValidator<D extends Record<string, any> = any, R extends RulesFor
831
831
  * Stop validation on first failure.
832
832
  */
833
833
  stopOnFirstFailure(): this;
834
- use(plugin: ValidatorPlugin): this;
834
+ use(plugin: ValidatorPlugin | ValidatorPlugin[]): this;
835
835
  withContext(context: Record<string, any>): this;
836
836
  getContext(): Record<string, any>;
837
837
  /**
@@ -1175,7 +1175,7 @@ declare class Validator<D extends Record<string, any> = any, R extends RulesForD
1175
1175
  * @param plugin The plugin to register
1176
1176
  * @returns The Validator class for chaining
1177
1177
  */
1178
- static use(plugin: ValidatorPlugin): typeof Validator;
1178
+ static use(plugin: ValidatorPlugin | ValidatorPlugin[]): typeof Validator;
1179
1179
  /**
1180
1180
  * Register a plugin with the validator.
1181
1181
  * Plugins can add rules, messages, and even override existing rules and messages.
@@ -1183,7 +1183,7 @@ declare class Validator<D extends Record<string, any> = any, R extends RulesForD
1183
1183
  * @param plugin The plugin to register
1184
1184
  * @returns The Validator instance for chaining
1185
1185
  */
1186
- use(plugin: ValidatorPlugin): this;
1186
+ use(plugin: ValidatorPlugin | ValidatorPlugin[]): this;
1187
1187
  /**
1188
1188
  * Run the validator and store results.
1189
1189
  */
package/dist/index.js CHANGED
@@ -2241,7 +2241,8 @@ var BaseValidator = class BaseValidator {
2241
2241
  this.messages = new ErrorBag();
2242
2242
  }
2243
2243
  static use(plugin) {
2244
- usePlugin(plugin);
2244
+ if (Array.isArray(plugin)) for (const p of plugin) usePlugin(p);
2245
+ else usePlugin(plugin);
2245
2246
  return this;
2246
2247
  }
2247
2248
  static useContext(context = {}) {
@@ -3222,7 +3223,8 @@ var Validator = class Validator {
3222
3223
  * @returns The Validator class for chaining
3223
3224
  */
3224
3225
  static use(plugin) {
3225
- usePlugin(plugin);
3226
+ if (Array.isArray(plugin)) for (const p of plugin) usePlugin(p);
3227
+ else usePlugin(plugin);
3226
3228
  return this;
3227
3229
  }
3228
3230
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kanun",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "description": "Framework-agnostic TypeScript-first validation library.",
5
5
  "type": "module",
6
6
  "files": [