@naturalcycles/nodejs-lib 15.45.0 → 15.46.0

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.
@@ -66,8 +66,8 @@ export declare class JsonSchemaStringBuilder<IN extends string = string, OUT = I
66
66
  constructor();
67
67
  regex(pattern: RegExp, opt?: JsonBuilderRuleOpt): this;
68
68
  pattern(pattern: string, opt?: JsonBuilderRuleOpt): this;
69
- min(minLength: number): this;
70
- max(maxLength: number): this;
69
+ minLength(minLength: number): this;
70
+ maxLength(maxLength: number): this;
71
71
  length(minLength: number, maxLength: number): this;
72
72
  email(opt?: Partial<JsonSchemaStringEmailOptions>): this;
73
73
  trim(): this;
@@ -115,6 +115,7 @@ export declare class JsonSchemaNumberBuilder<IN extends number = number, OUT = I
115
115
  lessThanOrEqual(value: number): this;
116
116
  moreThan(value: number): this;
117
117
  moreThanOrEqual(value: number): this;
118
+ equal(value: number): this;
118
119
  range(minimum: number, maximum: number, incl: Inclusiveness): this;
119
120
  int32(): this;
120
121
  int64(): this;
@@ -172,8 +173,10 @@ export declare class JsonSchemaObjectInferringBuilder<PROPS extends Record<strin
172
173
  }
173
174
  export declare class JsonSchemaArrayBuilder<IN, OUT, Opt> extends JsonSchemaAnyBuilder<IN[], OUT[], Opt> {
174
175
  constructor(itemsSchema: JsonSchemaAnyBuilder<IN, OUT, Opt>);
175
- min(minItems: number): this;
176
- max(maxItems: number): this;
176
+ minLength(minItems: number): this;
177
+ maxLength(maxItems: number): this;
178
+ length(minItems: number, maxItems: number): this;
179
+ exactLength(length: number): this;
177
180
  unique(uniqueItems: number): this;
178
181
  }
179
182
  export declare class JsonSchemaSet2Builder<IN, OUT, Opt> extends JsonSchemaAnyBuilder<Iterable<IN>, Set2<OUT>, Opt> {
@@ -185,11 +185,11 @@ export class JsonSchemaStringBuilder extends JsonSchemaAnyBuilder {
185
185
  Object.assign(this.schema, { pattern });
186
186
  return this;
187
187
  }
188
- min(minLength) {
188
+ minLength(minLength) {
189
189
  Object.assign(this.schema, { minLength });
190
190
  return this;
191
191
  }
192
- max(maxLength) {
192
+ maxLength(maxLength) {
193
193
  Object.assign(this.schema, { maxLength });
194
194
  return this;
195
195
  }
@@ -334,6 +334,9 @@ export class JsonSchemaNumberBuilder extends JsonSchemaAnyBuilder {
334
334
  moreThanOrEqual(value) {
335
335
  return this.min(value);
336
336
  }
337
+ equal(value) {
338
+ return this.min(value).max(value);
339
+ }
337
340
  range(minimum, maximum, incl) {
338
341
  if (incl === '[)') {
339
342
  return this.moreThanOrEqual(minimum).lessThan(maximum);
@@ -507,14 +510,20 @@ export class JsonSchemaArrayBuilder extends JsonSchemaAnyBuilder {
507
510
  items: itemsSchema.build(),
508
511
  });
509
512
  }
510
- min(minItems) {
513
+ minLength(minItems) {
511
514
  Object.assign(this.schema, { minItems });
512
515
  return this;
513
516
  }
514
- max(maxItems) {
517
+ maxLength(maxItems) {
515
518
  Object.assign(this.schema, { maxItems });
516
519
  return this;
517
520
  }
521
+ length(minItems, maxItems) {
522
+ return this.minLength(minItems).maxLength(maxItems);
523
+ }
524
+ exactLength(length) {
525
+ return this.minLength(length).maxLength(length);
526
+ }
518
527
  unique(uniqueItems) {
519
528
  Object.assign(this.schema, { uniqueItems });
520
529
  return this;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@naturalcycles/nodejs-lib",
3
3
  "type": "module",
4
- "version": "15.45.0",
4
+ "version": "15.46.0",
5
5
  "dependencies": {
6
6
  "@naturalcycles/js-lib": "^15",
7
7
  "@types/js-yaml": "^4",
@@ -256,12 +256,12 @@ export class JsonSchemaStringBuilder<
256
256
  return this
257
257
  }
258
258
 
259
- min(minLength: number): this {
259
+ minLength(minLength: number): this {
260
260
  Object.assign(this.schema, { minLength })
261
261
  return this
262
262
  }
263
263
 
264
- max(maxLength: number): this {
264
+ maxLength(maxLength: number): this {
265
265
  Object.assign(this.schema, { maxLength })
266
266
  return this
267
267
  }
@@ -452,6 +452,10 @@ export class JsonSchemaNumberBuilder<
452
452
  return this.min(value)
453
453
  }
454
454
 
455
+ equal(value: number): this {
456
+ return this.min(value).max(value)
457
+ }
458
+
455
459
  range(minimum: number, maximum: number, incl: Inclusiveness): this {
456
460
  if (incl === '[)') {
457
461
  return this.moreThanOrEqual(minimum).lessThan(maximum)
@@ -725,16 +729,24 @@ export class JsonSchemaArrayBuilder<IN, OUT, Opt> extends JsonSchemaAnyBuilder<I
725
729
  })
726
730
  }
727
731
 
728
- min(minItems: number): this {
732
+ minLength(minItems: number): this {
729
733
  Object.assign(this.schema, { minItems })
730
734
  return this
731
735
  }
732
736
 
733
- max(maxItems: number): this {
737
+ maxLength(maxItems: number): this {
734
738
  Object.assign(this.schema, { maxItems })
735
739
  return this
736
740
  }
737
741
 
742
+ length(minItems: number, maxItems: number): this {
743
+ return this.minLength(minItems).maxLength(maxItems)
744
+ }
745
+
746
+ exactLength(length: number): this {
747
+ return this.minLength(length).maxLength(length)
748
+ }
749
+
738
750
  unique(uniqueItems: number): this {
739
751
  Object.assign(this.schema, { uniqueItems })
740
752
  return this