@serum-enterprises/schema 3.0.0-beta.2 → 3.1.0-beta.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.
- package/build/index.js +345 -207
- package/build/index.js.map +3 -3
- package/package.json +1 -1
- package/types/Validator.d.ts +1 -0
- package/types/index.d.ts +1 -0
- package/types/lib/isEquals.d.ts +2 -0
- package/types/validators/Array.d.ts +1 -0
- package/types/validators/Boolean.d.ts +1 -0
- package/types/validators/JSON.d.ts +1 -0
- package/types/validators/Number.d.ts +1 -0
- package/types/validators/Object.d.ts +1 -0
- package/types/validators/String.d.ts +1 -0
package/build/index.js
CHANGED
|
@@ -221,6 +221,9 @@ var JSONValidator = class _JSONValidator extends Validator {
|
|
|
221
221
|
isSubset(other) {
|
|
222
222
|
return other instanceof _JSONValidator;
|
|
223
223
|
}
|
|
224
|
+
isEquals(other) {
|
|
225
|
+
return other instanceof _JSONValidator;
|
|
226
|
+
}
|
|
224
227
|
toJSON() {
|
|
225
228
|
return {
|
|
226
229
|
type: "json"
|
|
@@ -281,6 +284,17 @@ var BooleanValidator = class _BooleanValidator extends Validator {
|
|
|
281
284
|
}
|
|
282
285
|
return true;
|
|
283
286
|
}
|
|
287
|
+
isEquals(other) {
|
|
288
|
+
if (!(other instanceof _BooleanValidator))
|
|
289
|
+
return false;
|
|
290
|
+
if (this._nullable.isSome() !== other._nullable.isSome())
|
|
291
|
+
return false;
|
|
292
|
+
if (this._equals.isSome() !== other._equals.isSome())
|
|
293
|
+
return false;
|
|
294
|
+
if (this._equals.isSome() && other._equals.isSome() && this._equals.value !== other._equals.value)
|
|
295
|
+
return false;
|
|
296
|
+
return true;
|
|
297
|
+
}
|
|
284
298
|
toJSON() {
|
|
285
299
|
const definition = {
|
|
286
300
|
type: "boolean"
|
|
@@ -411,6 +425,27 @@ var NumberValidator = class _NumberValidator extends Validator {
|
|
|
411
425
|
return false;
|
|
412
426
|
return true;
|
|
413
427
|
}
|
|
428
|
+
isEquals(other) {
|
|
429
|
+
if (!(other instanceof _NumberValidator))
|
|
430
|
+
return false;
|
|
431
|
+
if (this._nullable.isSome() !== other._nullable.isSome())
|
|
432
|
+
return false;
|
|
433
|
+
if (this._integer.isSome() !== other._integer.isSome())
|
|
434
|
+
return false;
|
|
435
|
+
if (this._equals.isSome() !== other._equals.isSome())
|
|
436
|
+
return false;
|
|
437
|
+
if (this._equals.isSome() && other._equals.isSome() && this._equals.value !== other._equals.value)
|
|
438
|
+
return false;
|
|
439
|
+
if (this._min.isSome() !== other._min.isSome())
|
|
440
|
+
return false;
|
|
441
|
+
if (this._min.isSome() && other._min.isSome() && this._min.value !== other._min.value)
|
|
442
|
+
return false;
|
|
443
|
+
if (this._max.isSome() !== other._max.isSome())
|
|
444
|
+
return false;
|
|
445
|
+
if (this._max.isSome() && other._max.isSome() && this._max.value !== other._max.value)
|
|
446
|
+
return false;
|
|
447
|
+
return true;
|
|
448
|
+
}
|
|
414
449
|
toJSON() {
|
|
415
450
|
const definition = {
|
|
416
451
|
type: "number"
|
|
@@ -531,6 +566,25 @@ var StringValidator = class _StringValidator extends Validator {
|
|
|
531
566
|
return false;
|
|
532
567
|
return true;
|
|
533
568
|
}
|
|
569
|
+
isEquals(other) {
|
|
570
|
+
if (!(other instanceof _StringValidator))
|
|
571
|
+
return false;
|
|
572
|
+
if (this._nullable.isSome() !== other._nullable.isSome())
|
|
573
|
+
return false;
|
|
574
|
+
if (this._equals.isSome() !== other._equals.isSome())
|
|
575
|
+
return false;
|
|
576
|
+
if (this._equals.isSome() && other._equals.isSome() && this._equals.value !== other._equals.value)
|
|
577
|
+
return false;
|
|
578
|
+
if (this._min.isSome() !== other._min.isSome())
|
|
579
|
+
return false;
|
|
580
|
+
if (this._min.isSome() && other._min.isSome() && this._min.value !== other._min.value)
|
|
581
|
+
return false;
|
|
582
|
+
if (this._max.isSome() !== other._max.isSome())
|
|
583
|
+
return false;
|
|
584
|
+
if (this._max.isSome() && other._max.isSome() && this._max.value !== other._max.value)
|
|
585
|
+
return false;
|
|
586
|
+
return true;
|
|
587
|
+
}
|
|
534
588
|
toJSON() {
|
|
535
589
|
const definition = {
|
|
536
590
|
type: "string"
|
|
@@ -548,216 +602,32 @@ var StringValidator = class _StringValidator extends Validator {
|
|
|
548
602
|
};
|
|
549
603
|
|
|
550
604
|
// src/validators/Array.ts
|
|
551
|
-
var import_json5 = __toESM(require_build());
|
|
552
|
-
var import_option4 = __toESM(require_Option());
|
|
553
|
-
var ArrayValidator = class _ArrayValidator extends Validator {
|
|
554
|
-
static fromJSON(definition, path = "definition") {
|
|
555
|
-
const validatorInstance = new _ArrayValidator();
|
|
556
|
-
if ("nullable" in definition) {
|
|
557
|
-
if (!import_json5.JSON.isBoolean(definition["nullable"]))
|
|
558
|
-
throw new DefinitionError(`Expected ${path}.nullable to be a Boolean`);
|
|
559
|
-
validatorInstance.nullable(definition["nullable"]);
|
|
560
|
-
}
|
|
561
|
-
if ("min" in definition) {
|
|
562
|
-
if (!import_json5.JSON.isNumber(definition["min"]))
|
|
563
|
-
throw new DefinitionError(`Expected ${path}.min to be a Number`);
|
|
564
|
-
validatorInstance.min(definition["min"], `${path}.min`);
|
|
565
|
-
}
|
|
566
|
-
if ("max" in definition) {
|
|
567
|
-
if (!import_json5.JSON.isNumber(definition["max"]))
|
|
568
|
-
throw new DefinitionError(`Expected ${path}.max to be a Number`);
|
|
569
|
-
validatorInstance.max(definition["max"], `${path}.max`);
|
|
570
|
-
}
|
|
571
|
-
if ("every" in definition) {
|
|
572
|
-
if (!import_json5.JSON.isObject(definition["every"]))
|
|
573
|
-
throw new DefinitionError(`Expected ${path}.every to be an Object`);
|
|
574
|
-
validatorInstance.every(
|
|
575
|
-
fromJSON(definition["every"], `${path}.every`)
|
|
576
|
-
);
|
|
577
|
-
}
|
|
578
|
-
if ("tuple" in definition) {
|
|
579
|
-
if (!import_json5.JSON.isShallowArray(definition["tuple"]))
|
|
580
|
-
throw new DefinitionError(`Expected ${path}.tuple to be an Array`);
|
|
581
|
-
const tupleSchemas = [];
|
|
582
|
-
const errors = [];
|
|
583
|
-
definition["tuple"].forEach((tupleDef, index) => {
|
|
584
|
-
try {
|
|
585
|
-
tupleSchemas.push(fromJSON(tupleDef, `${path}.tuple[${index}]`));
|
|
586
|
-
} catch (e) {
|
|
587
|
-
if (!(e instanceof DefinitionError))
|
|
588
|
-
throw new DefinitionError(`Fatal Error: Undefined Error thrown by Domain.fromJSON at ${path}`);
|
|
589
|
-
errors.push(e);
|
|
590
|
-
}
|
|
591
|
-
});
|
|
592
|
-
if (errors.length > 0)
|
|
593
|
-
throw new DefinitionError(`Multiple Definition Errors detected at ${path} (see cause)`, { cause: errors });
|
|
594
|
-
validatorInstance.tuple(tupleSchemas, `${path}.tuple`);
|
|
595
|
-
}
|
|
596
|
-
return validatorInstance;
|
|
597
|
-
}
|
|
598
|
-
_nullable = import_option4.Option.None();
|
|
599
|
-
_every = import_option4.Option.None();
|
|
600
|
-
_tuple = import_option4.Option.None();
|
|
601
|
-
_min = import_option4.Option.None();
|
|
602
|
-
_max = import_option4.Option.None();
|
|
603
|
-
nullable(flag) {
|
|
604
|
-
this._nullable = flag ?? true ? import_option4.Option.Some(null) : import_option4.Option.None();
|
|
605
|
-
return this;
|
|
606
|
-
}
|
|
607
|
-
min(value, path = "min") {
|
|
608
|
-
if (this._max.isSome() && this._max.value < value)
|
|
609
|
-
throw new DefinitionError(`Expected Minimum Rule to be smaller than or equal to Maximum Rule at Path ${path}`);
|
|
610
|
-
if (this._tuple.isSome() && value < this._tuple.value.length)
|
|
611
|
-
throw new DefinitionError(`Expected Minimum Rule to be larger than or equal to Tuple Length at Path ${path}`);
|
|
612
|
-
this._min = import_option4.Option.Some(value);
|
|
613
|
-
return this;
|
|
614
|
-
}
|
|
615
|
-
max(value, path = "max") {
|
|
616
|
-
if (this._min.isSome() && this._min.value > value)
|
|
617
|
-
throw new DefinitionError(`Expected Maximum Rule to be larger than or equal to Minimum Rule at Path ${path}`);
|
|
618
|
-
if (this._tuple.isSome() && value < this._tuple.value.length)
|
|
619
|
-
throw new DefinitionError(`Expected Maximum Rule to be larger than or equal to Tuple Length at Path ${path}`);
|
|
620
|
-
this._max = import_option4.Option.Some(value);
|
|
621
|
-
return this;
|
|
622
|
-
}
|
|
623
|
-
every(validator) {
|
|
624
|
-
this._every = import_option4.Option.Some(validator);
|
|
625
|
-
return this;
|
|
626
|
-
}
|
|
627
|
-
/**
|
|
628
|
-
* Applies ONLY to prefix indices [0..validators.length - 1]
|
|
629
|
-
* If every() is set, prefix elements are effectively `T[i] & E`.
|
|
630
|
-
*/
|
|
631
|
-
tuple(validators, path = "tuple") {
|
|
632
|
-
if (this._min.isSome() && this._min.value < validators.length)
|
|
633
|
-
throw new DefinitionError(`Expected Tuple Length to be smaller than or equal to Minimum Rule at Path ${path}`);
|
|
634
|
-
if (this._max.isSome() && this._max.value < validators.length)
|
|
635
|
-
throw new DefinitionError(`Expected Tuple Length to be smaller than or equal to Maximum Rule at Path ${path}`);
|
|
636
|
-
this._tuple = import_option4.Option.Some(validators);
|
|
637
|
-
return this;
|
|
638
|
-
}
|
|
639
|
-
assert(data, path = "data") {
|
|
640
|
-
if (import_json5.JSON.isShallowArray(data)) {
|
|
641
|
-
if (this._min.isSome() && this._min.value > data.length)
|
|
642
|
-
throw new AssertError(`Expected ${path} to be at least ${this._min.value} Elements long`);
|
|
643
|
-
if (this._max.isSome() && this._max.value < data.length)
|
|
644
|
-
throw new AssertError(`Expected ${path} to be at most ${this._max.value} Elements long`);
|
|
645
|
-
const errors = [];
|
|
646
|
-
if (this._every.isSome()) {
|
|
647
|
-
const validator = this._every.value;
|
|
648
|
-
data.forEach((value, index) => {
|
|
649
|
-
try {
|
|
650
|
-
validator.assert(value, `${path}[${index}]`);
|
|
651
|
-
} catch (e) {
|
|
652
|
-
if (!(e instanceof AssertError))
|
|
653
|
-
throw new AssertError(`Fatal Error: Undefined Error thrown by an Assert Method at ${path}[${index}]`);
|
|
654
|
-
errors.push(e);
|
|
655
|
-
}
|
|
656
|
-
});
|
|
657
|
-
}
|
|
658
|
-
if (this._tuple.isSome()) {
|
|
659
|
-
if (data.length < this._tuple.value.length)
|
|
660
|
-
throw new AssertError(`Expected ${path} to be at least ${this._tuple.value.length} Elements long (Tuple Constraint)`);
|
|
661
|
-
this._tuple.value.forEach((validator, index) => {
|
|
662
|
-
try {
|
|
663
|
-
validator.assert(data[index], `${path}[${index}]`);
|
|
664
|
-
} catch (e) {
|
|
665
|
-
if (!(e instanceof AssertError))
|
|
666
|
-
throw new AssertError(`Fatal Error: Undefined Error thrown by an Assert Method at ${path}[${index}]`);
|
|
667
|
-
errors.push(e);
|
|
668
|
-
}
|
|
669
|
-
});
|
|
670
|
-
}
|
|
671
|
-
if (errors.length > 0)
|
|
672
|
-
throw new AssertError(`Multiple Errors while asserting ${path} (see cause)`, { cause: errors });
|
|
673
|
-
} else if (import_json5.JSON.isNull(data)) {
|
|
674
|
-
if (!this._nullable.isSome())
|
|
675
|
-
throw new AssertError(`Expected ${path} to be an Array${this._nullable.isSome() ? " or Null" : ""}`);
|
|
676
|
-
} else
|
|
677
|
-
throw new AssertError(`Expected ${path} to be an Array${this._nullable.isSome() ? " or Null" : ""}`);
|
|
678
|
-
}
|
|
679
|
-
isSubset(other) {
|
|
680
|
-
if (other instanceof JSONValidator)
|
|
681
|
-
return true;
|
|
682
|
-
if (!(other instanceof _ArrayValidator))
|
|
683
|
-
return false;
|
|
684
|
-
if (this._nullable.isSome() && !other._nullable.isSome())
|
|
685
|
-
return false;
|
|
686
|
-
const thisTupleLen = this._tuple.isSome() ? this._tuple.value.length : 0;
|
|
687
|
-
const otherTupleLen = other._tuple.isSome() ? other._tuple.value.length : 0;
|
|
688
|
-
const thisMin = this._min.isSome() ? this._min.value : 0;
|
|
689
|
-
const otherMin = other._min.isSome() ? other._min.value : 0;
|
|
690
|
-
const thisMax = this._max.isSome() ? this._max.value : Infinity;
|
|
691
|
-
const otherMax = other._max.isSome() ? other._max.value : Infinity;
|
|
692
|
-
const thisEffectiveMin = Math.max(thisMin, thisTupleLen);
|
|
693
|
-
const otherEffectiveMin = Math.max(otherMin, otherTupleLen);
|
|
694
|
-
if (thisEffectiveMin < otherEffectiveMin)
|
|
695
|
-
return false;
|
|
696
|
-
if (thisMax > otherMax)
|
|
697
|
-
return false;
|
|
698
|
-
const indexConjuncts = (i) => {
|
|
699
|
-
const conjuncts = [];
|
|
700
|
-
if (this._every.isSome())
|
|
701
|
-
conjuncts.push(this._every.value);
|
|
702
|
-
if (this._tuple.isSome() && i < this._tuple.value.length)
|
|
703
|
-
conjuncts.push(this._tuple.value[i]);
|
|
704
|
-
return conjuncts;
|
|
705
|
-
};
|
|
706
|
-
const conjunctsSubset = (conjuncts, target) => {
|
|
707
|
-
if (conjuncts.length === 0)
|
|
708
|
-
return false;
|
|
709
|
-
return conjuncts.some((c) => c.isSubset(target));
|
|
710
|
-
};
|
|
711
|
-
if (other._tuple.isSome()) {
|
|
712
|
-
for (let i = 0; i < other._tuple.value.length; i++) {
|
|
713
|
-
const aConj = indexConjuncts(i);
|
|
714
|
-
if (!conjunctsSubset(aConj, other._tuple.value[i]))
|
|
715
|
-
return false;
|
|
716
|
-
if (other._every.isSome() && !conjunctsSubset(aConj, other._every.value))
|
|
717
|
-
return false;
|
|
718
|
-
}
|
|
719
|
-
}
|
|
720
|
-
return !(other._every.isSome() && (thisMax === Infinity ? true : thisMax > Math.max(thisTupleLen, otherTupleLen)) && (!this._every.isSome() || !this._every.value.isSubset(other._every.value)));
|
|
721
|
-
}
|
|
722
|
-
toJSON() {
|
|
723
|
-
const definition = { type: "array" };
|
|
724
|
-
if (this._nullable.isSome())
|
|
725
|
-
definition.nullable = true;
|
|
726
|
-
if (this._min.isSome())
|
|
727
|
-
definition.min = this._min.value;
|
|
728
|
-
if (this._max.isSome())
|
|
729
|
-
definition.max = this._max.value;
|
|
730
|
-
if (this._every.isSome())
|
|
731
|
-
definition.every = this._every.value.toJSON();
|
|
732
|
-
if (this._tuple.isSome())
|
|
733
|
-
definition.tuple = this._tuple.value.map((validator) => validator.toJSON());
|
|
734
|
-
return definition;
|
|
735
|
-
}
|
|
736
|
-
};
|
|
737
|
-
|
|
738
|
-
// src/validators/Object.ts
|
|
739
605
|
var import_json6 = __toESM(require_build());
|
|
740
606
|
var import_option5 = __toESM(require_Option());
|
|
607
|
+
|
|
608
|
+
// src/validators/Object.ts
|
|
609
|
+
var import_json5 = __toESM(require_build());
|
|
610
|
+
var import_option4 = __toESM(require_Option());
|
|
741
611
|
var ObjectValidator = class _ObjectValidator extends Validator {
|
|
742
612
|
static fromJSON(definition, path = "definition") {
|
|
743
613
|
const validatorInstance = new _ObjectValidator();
|
|
744
614
|
if ("nullable" in definition) {
|
|
745
|
-
if (!
|
|
615
|
+
if (!import_json5.JSON.isBoolean(definition["nullable"]))
|
|
746
616
|
throw new DefinitionError(`Expected ${path}.nullable to be a Boolean`);
|
|
747
617
|
validatorInstance.nullable(definition["nullable"]);
|
|
748
618
|
}
|
|
749
619
|
if ("exact" in definition) {
|
|
750
|
-
if (!
|
|
620
|
+
if (!import_json5.JSON.isBoolean(definition["exact"]))
|
|
751
621
|
throw new DefinitionError(`Expected ${path}.exact to be a Boolean`);
|
|
752
622
|
validatorInstance.exact(definition["exact"], `${path}.exact`);
|
|
753
623
|
}
|
|
754
624
|
if ("min" in definition) {
|
|
755
|
-
if (!
|
|
625
|
+
if (!import_json5.JSON.isNumber(definition["min"]))
|
|
756
626
|
throw new DefinitionError(`Expected ${path}.min to be a Number`);
|
|
757
627
|
validatorInstance.min(definition["min"], `${path}.min`);
|
|
758
628
|
}
|
|
759
629
|
if ("max" in definition) {
|
|
760
|
-
if (!
|
|
630
|
+
if (!import_json5.JSON.isNumber(definition["max"]))
|
|
761
631
|
throw new DefinitionError(`Expected ${path}.max to be a Number`);
|
|
762
632
|
validatorInstance.max(definition["max"], `${path}.max`);
|
|
763
633
|
}
|
|
@@ -765,7 +635,7 @@ var ObjectValidator = class _ObjectValidator extends Validator {
|
|
|
765
635
|
validatorInstance.every(fromJSON(definition["every"], `${path}.every`));
|
|
766
636
|
}
|
|
767
637
|
if ("shape" in definition) {
|
|
768
|
-
if (!
|
|
638
|
+
if (!import_json5.JSON.isShallowObject(definition["shape"]))
|
|
769
639
|
throw new DefinitionError(`Expected ${path}.shape to be an Object`);
|
|
770
640
|
const shape = {};
|
|
771
641
|
const errors = [];
|
|
@@ -785,14 +655,14 @@ var ObjectValidator = class _ObjectValidator extends Validator {
|
|
|
785
655
|
}
|
|
786
656
|
return validatorInstance;
|
|
787
657
|
}
|
|
788
|
-
_nullable =
|
|
789
|
-
_min =
|
|
790
|
-
_max =
|
|
791
|
-
_every =
|
|
792
|
-
_shape =
|
|
793
|
-
_exact =
|
|
658
|
+
_nullable = import_option4.Option.None();
|
|
659
|
+
_min = import_option4.Option.None();
|
|
660
|
+
_max = import_option4.Option.None();
|
|
661
|
+
_every = import_option4.Option.None();
|
|
662
|
+
_shape = import_option4.Option.None();
|
|
663
|
+
_exact = import_option4.Option.None();
|
|
794
664
|
nullable(flag) {
|
|
795
|
-
this._nullable = flag ?? true ?
|
|
665
|
+
this._nullable = flag ?? true ? import_option4.Option.Some(null) : import_option4.Option.None();
|
|
796
666
|
return this;
|
|
797
667
|
}
|
|
798
668
|
min(value, path = "min") {
|
|
@@ -802,7 +672,7 @@ var ObjectValidator = class _ObjectValidator extends Validator {
|
|
|
802
672
|
throw new DefinitionError(`Expected Minimum Rule to be larger than or equal to Shape Key Count at Path ${path}`);
|
|
803
673
|
if (this._exact.isSome() && this._shape.isSome() && value > Object.keys(this._shape.value).length)
|
|
804
674
|
throw new DefinitionError(`Expected Minimum Rule to be smaller than or equal to Shape Key Count due to Exact Rule at Path ${path}`);
|
|
805
|
-
this._min =
|
|
675
|
+
this._min = import_option4.Option.Some(value);
|
|
806
676
|
return this;
|
|
807
677
|
}
|
|
808
678
|
max(value, path = "max") {
|
|
@@ -810,11 +680,11 @@ var ObjectValidator = class _ObjectValidator extends Validator {
|
|
|
810
680
|
throw new DefinitionError(`Expected Maximum Rule to be larger than or equal to Minimum Rule at Path ${path}`);
|
|
811
681
|
if (this._shape.isSome() && value < Object.keys(this._shape.value).length)
|
|
812
682
|
throw new DefinitionError(`Expected Maximum Rule to be larger than or equal to Shape Key Count at Path ${path}`);
|
|
813
|
-
this._max =
|
|
683
|
+
this._max = import_option4.Option.Some(value);
|
|
814
684
|
return this;
|
|
815
685
|
}
|
|
816
686
|
every(validator) {
|
|
817
|
-
this._every =
|
|
687
|
+
this._every = import_option4.Option.Some(validator);
|
|
818
688
|
return this;
|
|
819
689
|
}
|
|
820
690
|
shape(value, path = "shape") {
|
|
@@ -827,7 +697,7 @@ var ObjectValidator = class _ObjectValidator extends Validator {
|
|
|
827
697
|
throw new DefinitionError(`Expected Shape Key Count to be larger than or equal to Minimum Rule due to Exact Rule at Path ${path}`);
|
|
828
698
|
if (this._exact.isSome() && this._max.isSome() && this._max.value < shapeKeyCount)
|
|
829
699
|
throw new DefinitionError(`Expected Shape Key Count to be smaller than or equal to Maximum Rule due to Exact Rule at Path ${path}`);
|
|
830
|
-
this._shape =
|
|
700
|
+
this._shape = import_option4.Option.Some(value);
|
|
831
701
|
return this;
|
|
832
702
|
}
|
|
833
703
|
exact(flag, path = "exact") {
|
|
@@ -838,11 +708,11 @@ var ObjectValidator = class _ObjectValidator extends Validator {
|
|
|
838
708
|
if (this._max.isSome() && this._max.value < shapeKeyCount)
|
|
839
709
|
throw new DefinitionError(`Expected Exact Rule to be false due to Maximum Rule allowing fewer Properties than Shape defines at Path ${path}`);
|
|
840
710
|
}
|
|
841
|
-
this._exact = flag ?? true ?
|
|
711
|
+
this._exact = flag ?? true ? import_option4.Option.Some(null) : import_option4.Option.None();
|
|
842
712
|
return this;
|
|
843
713
|
}
|
|
844
714
|
assert(data, path = "data") {
|
|
845
|
-
if (
|
|
715
|
+
if (import_json5.JSON.isShallowObject(data)) {
|
|
846
716
|
const keys = Object.keys(data);
|
|
847
717
|
if (this._min.isSome() && keys.length < this._min.value)
|
|
848
718
|
throw new AssertError(`Expected ${path} to have at least ${this._min.value} Properties`);
|
|
@@ -882,7 +752,7 @@ var ObjectValidator = class _ObjectValidator extends Validator {
|
|
|
882
752
|
}
|
|
883
753
|
if (errors.length > 0)
|
|
884
754
|
throw new AssertError(`Multiple Errors while asserting ${path} (see cause)`, { cause: errors });
|
|
885
|
-
} else if (
|
|
755
|
+
} else if (import_json5.JSON.isNull(data)) {
|
|
886
756
|
if (!this._nullable.isSome())
|
|
887
757
|
throw new AssertError(`Expected ${path} to be an Object${this._nullable.isSome() ? " or Null" : ""}`);
|
|
888
758
|
} else
|
|
@@ -954,6 +824,39 @@ var ObjectValidator = class _ObjectValidator extends Validator {
|
|
|
954
824
|
}
|
|
955
825
|
return true;
|
|
956
826
|
}
|
|
827
|
+
isEquals(other) {
|
|
828
|
+
if (!(other instanceof _ObjectValidator))
|
|
829
|
+
return false;
|
|
830
|
+
if (this._nullable.isSome() !== other._nullable.isSome())
|
|
831
|
+
return false;
|
|
832
|
+
if (this._min.isSome() !== other._min.isSome())
|
|
833
|
+
return false;
|
|
834
|
+
if (this._min.isSome() && other._min.isSome() && this._min.value !== other._min.value)
|
|
835
|
+
return false;
|
|
836
|
+
if (this._max.isSome() !== other._max.isSome())
|
|
837
|
+
return false;
|
|
838
|
+
if (this._max.isSome() && other._max.isSome() && this._max.value !== other._max.value)
|
|
839
|
+
return false;
|
|
840
|
+
if (this._every.isSome() !== other._every.isSome())
|
|
841
|
+
return false;
|
|
842
|
+
if (this._every.isSome() && other._every.isSome())
|
|
843
|
+
return isEquals(this._every.value, other._every.value);
|
|
844
|
+
if (this._shape.isSome() !== other._shape.isSome())
|
|
845
|
+
return false;
|
|
846
|
+
if (this._shape.isSome() && other._shape.isSome()) {
|
|
847
|
+
if (Object.keys(this._shape.value).length !== Object.keys(other._shape.value).length)
|
|
848
|
+
return false;
|
|
849
|
+
for (const [k, v] of Object.entries(this._shape.value)) {
|
|
850
|
+
if (!(other._shape.value[k] instanceof Validator))
|
|
851
|
+
return false;
|
|
852
|
+
if (!isEquals(v, other._shape.value[k]))
|
|
853
|
+
return false;
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
if (this._exact.isSome() !== other._exact.isSome())
|
|
857
|
+
return false;
|
|
858
|
+
return true;
|
|
859
|
+
}
|
|
957
860
|
toJSON() {
|
|
958
861
|
const schema = { type: "object" };
|
|
959
862
|
if (this._nullable.isSome())
|
|
@@ -975,6 +878,238 @@ var ObjectValidator = class _ObjectValidator extends Validator {
|
|
|
975
878
|
}
|
|
976
879
|
};
|
|
977
880
|
|
|
881
|
+
// src/lib/isEquals.ts
|
|
882
|
+
function isEquals(a, b) {
|
|
883
|
+
if (a instanceof JSONValidator)
|
|
884
|
+
return a.isEquals(b);
|
|
885
|
+
if (a instanceof BooleanValidator)
|
|
886
|
+
return a.isEquals(b);
|
|
887
|
+
if (a instanceof NumberValidator)
|
|
888
|
+
return a.isEquals(b);
|
|
889
|
+
if (a instanceof StringValidator)
|
|
890
|
+
return a.isEquals(b);
|
|
891
|
+
if (a instanceof ArrayValidator)
|
|
892
|
+
return a.isEquals(b);
|
|
893
|
+
if (a instanceof ObjectValidator)
|
|
894
|
+
return a.isEquals(b);
|
|
895
|
+
return false;
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
// src/validators/Array.ts
|
|
899
|
+
var ArrayValidator = class _ArrayValidator extends Validator {
|
|
900
|
+
static fromJSON(definition, path = "definition") {
|
|
901
|
+
const validatorInstance = new _ArrayValidator();
|
|
902
|
+
if ("nullable" in definition) {
|
|
903
|
+
if (!import_json6.JSON.isBoolean(definition["nullable"]))
|
|
904
|
+
throw new DefinitionError(`Expected ${path}.nullable to be a Boolean`);
|
|
905
|
+
validatorInstance.nullable(definition["nullable"]);
|
|
906
|
+
}
|
|
907
|
+
if ("min" in definition) {
|
|
908
|
+
if (!import_json6.JSON.isNumber(definition["min"]))
|
|
909
|
+
throw new DefinitionError(`Expected ${path}.min to be a Number`);
|
|
910
|
+
validatorInstance.min(definition["min"], `${path}.min`);
|
|
911
|
+
}
|
|
912
|
+
if ("max" in definition) {
|
|
913
|
+
if (!import_json6.JSON.isNumber(definition["max"]))
|
|
914
|
+
throw new DefinitionError(`Expected ${path}.max to be a Number`);
|
|
915
|
+
validatorInstance.max(definition["max"], `${path}.max`);
|
|
916
|
+
}
|
|
917
|
+
if ("every" in definition) {
|
|
918
|
+
if (!import_json6.JSON.isObject(definition["every"]))
|
|
919
|
+
throw new DefinitionError(`Expected ${path}.every to be an Object`);
|
|
920
|
+
validatorInstance.every(
|
|
921
|
+
fromJSON(definition["every"], `${path}.every`)
|
|
922
|
+
);
|
|
923
|
+
}
|
|
924
|
+
if ("tuple" in definition) {
|
|
925
|
+
if (!import_json6.JSON.isShallowArray(definition["tuple"]))
|
|
926
|
+
throw new DefinitionError(`Expected ${path}.tuple to be an Array`);
|
|
927
|
+
const tupleSchemas = [];
|
|
928
|
+
const errors = [];
|
|
929
|
+
definition["tuple"].forEach((tupleDef, index) => {
|
|
930
|
+
try {
|
|
931
|
+
tupleSchemas.push(fromJSON(tupleDef, `${path}.tuple[${index}]`));
|
|
932
|
+
} catch (e) {
|
|
933
|
+
if (!(e instanceof DefinitionError))
|
|
934
|
+
throw new DefinitionError(`Fatal Error: Undefined Error thrown by Domain.fromJSON at ${path}`);
|
|
935
|
+
errors.push(e);
|
|
936
|
+
}
|
|
937
|
+
});
|
|
938
|
+
if (errors.length > 0)
|
|
939
|
+
throw new DefinitionError(`Multiple Definition Errors detected at ${path} (see cause)`, { cause: errors });
|
|
940
|
+
validatorInstance.tuple(tupleSchemas, `${path}.tuple`);
|
|
941
|
+
}
|
|
942
|
+
return validatorInstance;
|
|
943
|
+
}
|
|
944
|
+
_nullable = import_option5.Option.None();
|
|
945
|
+
_every = import_option5.Option.None();
|
|
946
|
+
_tuple = import_option5.Option.None();
|
|
947
|
+
_min = import_option5.Option.None();
|
|
948
|
+
_max = import_option5.Option.None();
|
|
949
|
+
nullable(flag) {
|
|
950
|
+
this._nullable = flag ?? true ? import_option5.Option.Some(null) : import_option5.Option.None();
|
|
951
|
+
return this;
|
|
952
|
+
}
|
|
953
|
+
min(value, path = "min") {
|
|
954
|
+
if (this._max.isSome() && this._max.value < value)
|
|
955
|
+
throw new DefinitionError(`Expected Minimum Rule to be smaller than or equal to Maximum Rule at Path ${path}`);
|
|
956
|
+
if (this._tuple.isSome() && value < this._tuple.value.length)
|
|
957
|
+
throw new DefinitionError(`Expected Minimum Rule to be larger than or equal to Tuple Length at Path ${path}`);
|
|
958
|
+
this._min = import_option5.Option.Some(value);
|
|
959
|
+
return this;
|
|
960
|
+
}
|
|
961
|
+
max(value, path = "max") {
|
|
962
|
+
if (this._min.isSome() && this._min.value > value)
|
|
963
|
+
throw new DefinitionError(`Expected Maximum Rule to be larger than or equal to Minimum Rule at Path ${path}`);
|
|
964
|
+
if (this._tuple.isSome() && value < this._tuple.value.length)
|
|
965
|
+
throw new DefinitionError(`Expected Maximum Rule to be larger than or equal to Tuple Length at Path ${path}`);
|
|
966
|
+
this._max = import_option5.Option.Some(value);
|
|
967
|
+
return this;
|
|
968
|
+
}
|
|
969
|
+
every(validator) {
|
|
970
|
+
this._every = import_option5.Option.Some(validator);
|
|
971
|
+
return this;
|
|
972
|
+
}
|
|
973
|
+
/**
|
|
974
|
+
* Applies ONLY to prefix indices [0..validators.length - 1]
|
|
975
|
+
* If every() is set, prefix elements are effectively `T[i] & E`.
|
|
976
|
+
*/
|
|
977
|
+
tuple(validators, path = "tuple") {
|
|
978
|
+
if (this._min.isSome() && this._min.value < validators.length)
|
|
979
|
+
throw new DefinitionError(`Expected Tuple Length to be smaller than or equal to Minimum Rule at Path ${path}`);
|
|
980
|
+
if (this._max.isSome() && this._max.value < validators.length)
|
|
981
|
+
throw new DefinitionError(`Expected Tuple Length to be smaller than or equal to Maximum Rule at Path ${path}`);
|
|
982
|
+
this._tuple = import_option5.Option.Some(validators);
|
|
983
|
+
return this;
|
|
984
|
+
}
|
|
985
|
+
assert(data, path = "data") {
|
|
986
|
+
if (import_json6.JSON.isShallowArray(data)) {
|
|
987
|
+
if (this._min.isSome() && this._min.value > data.length)
|
|
988
|
+
throw new AssertError(`Expected ${path} to be at least ${this._min.value} Elements long`);
|
|
989
|
+
if (this._max.isSome() && this._max.value < data.length)
|
|
990
|
+
throw new AssertError(`Expected ${path} to be at most ${this._max.value} Elements long`);
|
|
991
|
+
const errors = [];
|
|
992
|
+
if (this._every.isSome()) {
|
|
993
|
+
const validator = this._every.value;
|
|
994
|
+
data.forEach((value, index) => {
|
|
995
|
+
try {
|
|
996
|
+
validator.assert(value, `${path}[${index}]`);
|
|
997
|
+
} catch (e) {
|
|
998
|
+
if (!(e instanceof AssertError))
|
|
999
|
+
throw new AssertError(`Fatal Error: Undefined Error thrown by an Assert Method at ${path}[${index}]`);
|
|
1000
|
+
errors.push(e);
|
|
1001
|
+
}
|
|
1002
|
+
});
|
|
1003
|
+
}
|
|
1004
|
+
if (this._tuple.isSome()) {
|
|
1005
|
+
if (data.length < this._tuple.value.length)
|
|
1006
|
+
throw new AssertError(`Expected ${path} to be at least ${this._tuple.value.length} Elements long (Tuple Constraint)`);
|
|
1007
|
+
this._tuple.value.forEach((validator, index) => {
|
|
1008
|
+
try {
|
|
1009
|
+
validator.assert(data[index], `${path}[${index}]`);
|
|
1010
|
+
} catch (e) {
|
|
1011
|
+
if (!(e instanceof AssertError))
|
|
1012
|
+
throw new AssertError(`Fatal Error: Undefined Error thrown by an Assert Method at ${path}[${index}]`);
|
|
1013
|
+
errors.push(e);
|
|
1014
|
+
}
|
|
1015
|
+
});
|
|
1016
|
+
}
|
|
1017
|
+
if (errors.length > 0)
|
|
1018
|
+
throw new AssertError(`Multiple Errors while asserting ${path} (see cause)`, { cause: errors });
|
|
1019
|
+
} else if (import_json6.JSON.isNull(data)) {
|
|
1020
|
+
if (!this._nullable.isSome())
|
|
1021
|
+
throw new AssertError(`Expected ${path} to be an Array${this._nullable.isSome() ? " or Null" : ""}`);
|
|
1022
|
+
} else
|
|
1023
|
+
throw new AssertError(`Expected ${path} to be an Array${this._nullable.isSome() ? " or Null" : ""}`);
|
|
1024
|
+
}
|
|
1025
|
+
isSubset(other) {
|
|
1026
|
+
if (other instanceof JSONValidator)
|
|
1027
|
+
return true;
|
|
1028
|
+
if (!(other instanceof _ArrayValidator))
|
|
1029
|
+
return false;
|
|
1030
|
+
if (this._nullable.isSome() && !other._nullable.isSome())
|
|
1031
|
+
return false;
|
|
1032
|
+
const thisTupleLen = this._tuple.isSome() ? this._tuple.value.length : 0;
|
|
1033
|
+
const otherTupleLen = other._tuple.isSome() ? other._tuple.value.length : 0;
|
|
1034
|
+
const thisMin = this._min.isSome() ? this._min.value : 0;
|
|
1035
|
+
const otherMin = other._min.isSome() ? other._min.value : 0;
|
|
1036
|
+
const thisMax = this._max.isSome() ? this._max.value : Infinity;
|
|
1037
|
+
const otherMax = other._max.isSome() ? other._max.value : Infinity;
|
|
1038
|
+
const thisEffectiveMin = Math.max(thisMin, thisTupleLen);
|
|
1039
|
+
const otherEffectiveMin = Math.max(otherMin, otherTupleLen);
|
|
1040
|
+
if (thisEffectiveMin < otherEffectiveMin)
|
|
1041
|
+
return false;
|
|
1042
|
+
if (thisMax > otherMax)
|
|
1043
|
+
return false;
|
|
1044
|
+
const indexConjuncts = (i) => {
|
|
1045
|
+
const conjuncts = [];
|
|
1046
|
+
if (this._every.isSome())
|
|
1047
|
+
conjuncts.push(this._every.value);
|
|
1048
|
+
if (this._tuple.isSome() && i < this._tuple.value.length)
|
|
1049
|
+
conjuncts.push(this._tuple.value[i]);
|
|
1050
|
+
return conjuncts;
|
|
1051
|
+
};
|
|
1052
|
+
const conjunctsSubset = (conjuncts, target) => {
|
|
1053
|
+
if (conjuncts.length === 0)
|
|
1054
|
+
return false;
|
|
1055
|
+
return conjuncts.some((c) => c.isSubset(target));
|
|
1056
|
+
};
|
|
1057
|
+
if (other._tuple.isSome()) {
|
|
1058
|
+
for (let i = 0; i < other._tuple.value.length; i++) {
|
|
1059
|
+
const aConj = indexConjuncts(i);
|
|
1060
|
+
if (!conjunctsSubset(aConj, other._tuple.value[i]))
|
|
1061
|
+
return false;
|
|
1062
|
+
if (other._every.isSome() && !conjunctsSubset(aConj, other._every.value))
|
|
1063
|
+
return false;
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
return !(other._every.isSome() && (thisMax === Infinity ? true : thisMax > Math.max(thisTupleLen, otherTupleLen)) && (!this._every.isSome() || !this._every.value.isSubset(other._every.value)));
|
|
1067
|
+
}
|
|
1068
|
+
isEquals(other) {
|
|
1069
|
+
if (!(other instanceof _ArrayValidator))
|
|
1070
|
+
return false;
|
|
1071
|
+
if (this._nullable.isSome() !== other._nullable.isSome())
|
|
1072
|
+
return false;
|
|
1073
|
+
if (this._min.isSome() !== other._min.isSome())
|
|
1074
|
+
return false;
|
|
1075
|
+
if (this._min.isSome() && other._min.isSome() && this._min.value !== other._min.value)
|
|
1076
|
+
return false;
|
|
1077
|
+
if (this._max.isSome() !== other._max.isSome())
|
|
1078
|
+
return false;
|
|
1079
|
+
if (this._max.isSome() && other._max.isSome() && this._max.value !== other._max.value)
|
|
1080
|
+
return false;
|
|
1081
|
+
if (this._every.isSome() !== other._every.isSome())
|
|
1082
|
+
return false;
|
|
1083
|
+
if (this._every.isSome() && other._every.isSome() && !isEquals(this._every.value, other._every.value))
|
|
1084
|
+
return false;
|
|
1085
|
+
if (this._tuple.isSome() !== other._tuple.isSome())
|
|
1086
|
+
return false;
|
|
1087
|
+
if (this._tuple.isSome() && other._tuple.isSome()) {
|
|
1088
|
+
if (this._tuple.value.length !== other._tuple.value.length)
|
|
1089
|
+
return false;
|
|
1090
|
+
for (let i = 0; i < this._tuple.value.length; i++) {
|
|
1091
|
+
if (!isEquals(this._tuple.value[i], other._tuple.value[i]))
|
|
1092
|
+
return false;
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
return true;
|
|
1096
|
+
}
|
|
1097
|
+
toJSON() {
|
|
1098
|
+
const definition = { type: "array" };
|
|
1099
|
+
if (this._nullable.isSome())
|
|
1100
|
+
definition.nullable = true;
|
|
1101
|
+
if (this._min.isSome())
|
|
1102
|
+
definition.min = this._min.value;
|
|
1103
|
+
if (this._max.isSome())
|
|
1104
|
+
definition.max = this._max.value;
|
|
1105
|
+
if (this._every.isSome())
|
|
1106
|
+
definition.every = this._every.value.toJSON();
|
|
1107
|
+
if (this._tuple.isSome())
|
|
1108
|
+
definition.tuple = this._tuple.value.map((validator) => validator.toJSON());
|
|
1109
|
+
return definition;
|
|
1110
|
+
}
|
|
1111
|
+
};
|
|
1112
|
+
|
|
978
1113
|
// src/lib/fromJSON.ts
|
|
979
1114
|
function fromJSON(definition, path) {
|
|
980
1115
|
if (!import_json7.JSON.isShallowObject(definition))
|
|
@@ -1022,6 +1157,9 @@ var Schema = class {
|
|
|
1022
1157
|
static fromJSON(definition, path = "definition") {
|
|
1023
1158
|
return fromJSON(definition, path);
|
|
1024
1159
|
}
|
|
1160
|
+
static isEquals(a, b) {
|
|
1161
|
+
return isEquals(a, b);
|
|
1162
|
+
}
|
|
1025
1163
|
};
|
|
1026
1164
|
var Validators = {
|
|
1027
1165
|
JSON: JSONValidator,
|
package/build/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../node_modules/@serum-enterprises/json/build/index.js", "../node_modules/@serum-enterprises/option/build/Option.js", "../src/index.ts", "../src/Validator.ts", "../src/lib/fromJSON.ts", "../src/validators/JSON.ts", "../src/lib/util.ts", "../src/validators/Boolean.ts", "../src/validators/Number.ts", "../src/validators/String.ts", "../src/validators/Array.ts", "../src/validators/Object.ts"],
|
|
4
|
-
"sourcesContent": ["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.JSON = void 0;\nvar JSON;\n(function (JSON) {\n function isNull(value) {\n return value === null;\n }\n JSON.isNull = isNull;\n function isBoolean(value) {\n return typeof value === 'boolean';\n }\n JSON.isBoolean = isBoolean;\n function isNumber(value) {\n // Using Number.isFinite here as NaN, Infinity and -Infinity are not valid JSON Numbers\n return Number.isFinite(value);\n }\n JSON.isNumber = isNumber;\n function isInteger(value) {\n // Using Number.isSafeInteger here as JS Numbers are 64-bit floating point numbers and not all integers can be represented accurately\n return Number.isSafeInteger(value);\n }\n JSON.isInteger = isInteger;\n function isString(value) {\n return typeof value === 'string';\n }\n JSON.isString = isString;\n function isShallowArray(value) {\n return Array.isArray(value);\n }\n JSON.isShallowArray = isShallowArray;\n function isArray(value) {\n return isShallowArray(value) && value.every((v) => isJSON(v));\n }\n JSON.isArray = isArray;\n function isShallowObject(value) {\n // Using Object.prototype.toString.call here as it is the most reliable way to check if something is an Object\n return (Object.prototype.toString.call(value) === '[object Object]');\n }\n JSON.isShallowObject = isShallowObject;\n function isObject(value) {\n return isShallowObject(value) && Object.values(value).every((v) => isJSON(v));\n }\n JSON.isObject = isObject;\n function isPrimitive(value) {\n return isBoolean(value) || isNumber(value) || isString(value);\n }\n JSON.isPrimitive = isPrimitive;\n function isShallowContainer(value) {\n return isShallowArray(value) || isShallowObject(value);\n }\n JSON.isShallowContainer = isShallowContainer;\n function isContainer(value) {\n return isArray(value) || isObject(value);\n }\n JSON.isContainer = isContainer;\n function isShallowJSON(value) {\n return isNull(value) || isPrimitive(value) || isShallowArray(value) || isShallowObject(value);\n }\n JSON.isShallowJSON = isShallowJSON;\n function isJSON(value) {\n return isNull(value) || isPrimitive(value) || isContainer(value);\n }\n JSON.isJSON = isJSON;\n function clone(value) {\n // Using Shallow Checks here as it is expected that value is JSON anyway, and this function is recursive anyway\n if (isShallowObject(value))\n return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, clone(v)]));\n else if (isShallowArray(value))\n return value.map((v) => clone(v));\n else\n return value;\n }\n JSON.clone = clone;\n // Compatibility Method for the native JSON.parse\n function parse(value) {\n return globalThis.JSON.parse(value);\n }\n JSON.parse = parse;\n // Compatibility Method for the native JSON.stringify\n function stringify(value) {\n return globalThis.JSON.stringify(value);\n }\n JSON.stringify = stringify;\n})(JSON || (exports.JSON = JSON = {}));\n", "\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.None = exports.Some = exports.Option = void 0;\nclass Option {\n static Some(value) {\n return new Some(value);\n }\n static None() {\n return new None();\n }\n isSome() {\n return this instanceof Some;\n }\n isNone() {\n return this instanceof None;\n }\n onSome(fn) {\n if (this.isSome())\n fn(this.value);\n return this;\n }\n onNone(fn) {\n if (this.isNone())\n fn();\n return this;\n }\n map(fn) {\n return this.match(value => Option.Some(fn(value)), () => Option.None());\n }\n match(onSome, onNone) {\n if (this.isSome())\n return onSome(this.value);\n else\n return onNone();\n }\n}\nexports.Option = Option;\nclass Some extends Option {\n _value;\n constructor(value) {\n super();\n this._value = value;\n }\n get value() {\n return this._value;\n }\n}\nexports.Some = Some;\nclass None extends Option {\n}\nexports.None = None;\n", "import {Validator} from './Validator';\nimport {fromJSON} from './lib/fromJSON';\n\nexport {Validator};\n\nimport {JSONValidator, JSONValidatorDefinition} from './validators/JSON';\nimport {BooleanValidator, BooleanValidatorDefinition} from './validators/Boolean';\nimport {NumberValidator, NumberValidatorDefinition} from './validators/Number';\nimport {StringValidator, StringValidatorDefinition} from './validators/String';\nimport {ArrayValidator, ArrayValidatorDefinition} from './validators/Array';\nimport {ObjectValidator, ObjectValidatorDefinition} from './validators/Object';\n\nexport class Schema {\n\tstatic get JSON(): JSONValidator {\n\t\treturn new JSONValidator();\n\t}\n\n\tstatic get Boolean(): BooleanValidator {\n\t\treturn new BooleanValidator();\n\t}\n\n\tstatic get Number(): NumberValidator {\n\t\treturn new NumberValidator();\n\t}\n\n\tstatic get String(): StringValidator {\n\t\treturn new StringValidator();\n\t}\n\n\tstatic get Array(): ArrayValidator {\n\t\treturn new ArrayValidator();\n\t}\n\n\tstatic get Object(): ObjectValidator {\n\t\treturn new ObjectValidator();\n\t}\n\n\tstatic fromJSON(definition: unknown, path: string = 'definition'): Validator {\n\t\treturn fromJSON(definition, path);\n\t}\n}\n\nexport const Validators = {\n\tJSON: JSONValidator,\n\tBoolean: BooleanValidator,\n\tNumber: NumberValidator,\n\tString: StringValidator,\n\tArray: ArrayValidator,\n\tObject: ObjectValidator\n} as const;\n\nexport type Definition =\n\tJSONValidatorDefinition |\n\tBooleanValidatorDefinition |\n\tNumberValidatorDefinition |\n\tStringValidatorDefinition |\n\tArrayValidatorDefinition |\n\tObjectValidatorDefinition;\n\nexport namespace Definitions {\n\texport type JSON = JSONValidatorDefinition;\n\texport type Boolean = BooleanValidatorDefinition;\n\texport type Number = NumberValidatorDefinition;\n\texport type String = StringValidatorDefinition;\n\texport type Array = ArrayValidatorDefinition;\n\texport type Object = ObjectValidatorDefinition;\n}\n\nexport {InferDefinitionType, InferValidatorReturnType} from './lib/util';", "import {Definition} from './lib/util';\n\nexport abstract class Validator<T = unknown> {\n\tpublic abstract assert(data: unknown, path: string): asserts data is T;\n\tpublic abstract isSubset(other: Validator): boolean;\n\n\tpublic validate(data: unknown, path: string = 'data'): T {\n\t\tthis.assert(data, path);\n\n\t\treturn data;\n\t}\n\n\tpublic is(data: unknown, path: string = 'data'): data is T {\n\t\ttry {\n\t\t\tthis.assert(data, path);\n\t\t\treturn true;\n\t\t} catch (e) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tpublic abstract toJSON(): Definition;\n}", "import {JSON} from '@serum-enterprises/json';\nimport type {Validator} from '../Validator';\nimport {JSONValidator} from '../validators/JSON';\nimport {BooleanValidator} from '../validators/Boolean';\nimport {NumberValidator} from '../validators/Number';\nimport {StringValidator} from '../validators/String';\nimport {ArrayValidator} from '../validators/Array';\nimport {ObjectValidator} from '../validators/Object';\nimport {Definition, DefinitionError} from './util';\n\nexport function fromJSON(\n\tdefinition: unknown,\n\tpath: string\n): Validator {\n\tif (!JSON.isShallowObject(definition))\n\t\tthrow new DefinitionError(`Expected ${path} to be an Object`);\n\n\tif (!JSON.isString(definition['type']))\n\t\tthrow new DefinitionError(`Expected ${path}.type to be a String`);\n\n\tswitch(definition['type']) {\n\t\tcase 'json':\n\t\t\treturn JSONValidator.fromJSON(definition as Definition & {[key: string]: unknown}, path);\n\t\tcase 'boolean':\n\t\t\treturn BooleanValidator.fromJSON(definition as Definition & {[key: string]: unknown}, path);\n\t\tcase 'number':\n\t\t\treturn NumberValidator.fromJSON(definition as Definition & {[key: string]: unknown}, path);\n\t\tcase 'string':\n\t\t\treturn StringValidator.fromJSON(definition as Definition & {[key: string]: unknown}, path);\n\t\tcase 'array':\n\t\t\treturn ArrayValidator.fromJSON(definition as Definition & {[key: string]: unknown}, path);\n\t\tcase 'object':\n\t\t\treturn ObjectValidator.fromJSON(definition as Definition & {[key: string]: unknown}, path);\n\t\tdefault:\n\t\t\tthrow new DefinitionError(`Expected ${path}.type to be a registered Validator`);\n\t}\n}", "import {JSON} from '@serum-enterprises/json';\nimport {Validator} from '../Validator';\nimport {Definition, AssertError} from '../lib/util';\n\nexport interface JSONValidatorDefinition extends Definition {\n\ttype: 'json';\n}\n\nexport class JSONValidator<T extends JSON.JSON = JSON.JSON> extends Validator<T> {\n\tpublic static fromJSON(\n\t\t_definition: Definition & { [key: string]: unknown },\n\t\t_path: string = 'definition'\n\t): Validator {\n\t\treturn new JSONValidator();\n\t}\n\n\tpublic assert(data: unknown, path: string = 'data'): asserts data is JSON.JSON {\n\t\tif (!JSON.isJSON(data))\n\t\t\tthrow new AssertError(`Expected ${path} to be valid JSON`);\n\t}\n\n\tpublic isSubset(other: Validator): boolean {\n\t\treturn other instanceof JSONValidator;\n\t}\n\n\tpublic toJSON(): JSONValidatorDefinition {\n\t\treturn {\n\t\t\ttype: 'json'\n\t\t};\n\t}\n}", "import type {Validator} from '../Validator';\n\nexport type ApplyNullability<T, N extends boolean> =\n\tN extends true ? T | null : Exclude<T, null>;\n\nexport interface Definition {\n\ttype: string;\n}\n\nexport type InferDefinitionType<V> = V extends { toJSON(): infer D } ? D : never;\nexport type InferValidatorReturnType<V> = V extends Validator<infer T> ? T : unknown;\n\nexport type InferListDefinitionType<T extends readonly Validator[]> = {\n\t[K in keyof T]: InferDefinitionType<T[K]>;\n};\nexport type InferListReturnType<T> = T extends readonly Validator[] ?\n\t{ [K in keyof T]: InferValidatorReturnType<T[K]> } :\n\tunknown;\n\nexport type InferObjectDefinitionType<T extends { [key: string]: Validator }> = {\n\t[K in keyof T]: InferDefinitionType<T[K]>\n}\nexport type InferObjectReturnType<T> = T extends { [key: string]: Validator } ?\n\t{ [K in keyof T]: InferValidatorReturnType<T[K]> } :\n\tunknown;\n\nexport class AssertError extends Error {}\n\nexport class DefinitionError extends Error {}", "import {JSON} from '@serum-enterprises/json';\nimport {Option} from '@serum-enterprises/option';\nimport {Validator} from '../Validator';\nimport {Definition, ApplyNullability, AssertError, DefinitionError} from '../lib/util';\nimport {JSONValidator} from './JSON';\n\nexport interface BooleanValidatorDefinition extends Definition {\n\ttype: 'boolean';\n\tnullable?: boolean;\n\tequals?: boolean;\n}\n\nexport class BooleanValidator<\n\tT extends JSON.Boolean = JSON.Boolean,\n\tN extends boolean = false\n> extends Validator<ApplyNullability<T, N>> {\n\tpublic static fromJSON(\n\t\tdefinition: Definition & { [key: string]: unknown },\n\t\tpath: string = 'definition'\n\t): Validator {\n\t\tconst validatorInstance = new BooleanValidator();\n\n\t\tif ('nullable' in definition) {\n\t\t\tif (!JSON.isBoolean(definition['nullable']))\n\t\t\t\tthrow new DefinitionError(`Expected ${path}.nullable to be a Boolean`);\n\n\t\t\tvalidatorInstance.nullable(definition['nullable']);\n\t\t}\n\n\t\tif ('equals' in definition) {\n\t\t\tif (!JSON.isBoolean(definition['equals']))\n\t\t\t\tthrow new DefinitionError(`Expected ${path}.equals to be a Boolean`);\n\n\t\t\tvalidatorInstance.equals(definition['equals']);\n\t\t}\n\n\t\treturn validatorInstance;\n\t}\n\n\tprotected _nullable: Option<null> = Option.None();\n\tprotected _equals: Option<boolean> = Option.None();\n\n\tpublic nullable<const F extends boolean = true>(flag?: F): BooleanValidator<T, F> {\n\t\tthis._nullable = flag ?? true ? Option.Some(null) : Option.None();\n\n\t\treturn this as unknown as BooleanValidator<T, F>;\n\t}\n\n\tpublic equals<const V extends boolean>(value: V): BooleanValidator<V, N> {\n\t\tthis._equals = Option.Some(value);\n\n\t\treturn this as unknown as BooleanValidator<V, N>;\n\t}\n\n\tpublic assert(data: unknown, path: string = 'data'): asserts data is ApplyNullability<T, N> {\n\t\tif (JSON.isBoolean(data)) {\n\t\t\tif (this._equals.isSome() && this._equals.value !== data)\n\t\t\t\tthrow new AssertError(`Expected ${path} to be ${this._equals.value}${this._nullable.isSome() ? '' : ' or Null'}`);\n\t\t}\n\t\telse if(JSON.isNull(data)) {\n\t\t\tif(!this._nullable.isSome())\n\t\t\t\tthrow new AssertError(`Expected ${path} to be a Boolean${this._nullable.isSome() ? ' or Null' : ''}`);\n\t\t}\n\t\telse\n\t\t\tthrow new AssertError(`Expected ${path} to be a Boolean${this._nullable.isSome() ? ' or Null' : ''}`);\n\t}\n\n\tpublic isSubset(other: Validator): boolean {\n\t\tif (other instanceof JSONValidator)\n\t\t\treturn true;\n\n\t\tif (!(other instanceof BooleanValidator))\n\t\t\treturn false;\n\n\t\tif (this._nullable.isSome() && !other._nullable.isSome())\n\t\t\treturn false;\n\n\t\tif (other._equals.isSome()) {\n\t\t\tif (this._equals.isSome())\n\t\t\t\treturn this._equals.value === other._equals.value;\n\t\t\telse\n\t\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tpublic toJSON(): BooleanValidatorDefinition {\n\t\tconst definition: BooleanValidatorDefinition = {\n\t\t\ttype: 'boolean'\n\t\t};\n\n\t\tif (this._nullable.isSome())\n\t\t\tdefinition['nullable'] = true;\n\n\t\tif (this._equals.isSome())\n\t\t\tdefinition['equals'] = this._equals.value;\n\n\t\treturn definition;\n\t}\n}", "import {JSON} from '@serum-enterprises/json';\nimport {Option} from '@serum-enterprises/option';\nimport {Validator} from '../Validator';\nimport {Definition, ApplyNullability, AssertError, DefinitionError} from '../lib/util';\nimport {JSONValidator} from './JSON';\n\nexport interface NumberValidatorDefinition extends Definition {\n\ttype: 'number';\n\tnullable?: boolean;\n\tequals?: JSON.Number;\n\tinteger?: boolean;\n\tmin?: number;\n\tmax?: number;\n}\n\nexport class NumberValidator<\n\tT extends JSON.Number = JSON.Number,\n\tN extends boolean = false\n> extends Validator<ApplyNullability<T, N>> {\n\tpublic static fromJSON(\n\t\tdefinition: Definition & { [key: string]: unknown },\n\t\tpath: string = 'definition'\n\t): Validator {\n\t\tconst validatorInstance = new NumberValidator();\n\n\t\tif ('nullable' in definition) {\n\t\t\tif (!JSON.isBoolean(definition['nullable']))\n\t\t\t\tthrow new DefinitionError(`Expected ${path}.nullable to be a Boolean`);\n\n\t\t\tvalidatorInstance.nullable(definition['nullable']);\n\t\t}\n\n\t\tif ('equals' in definition) {\n\t\t\tif (!JSON.isNumber(definition['equals']))\n\t\t\t\tthrow new DefinitionError(`Expected ${path}.equals to be a Number`);\n\n\t\t\tvalidatorInstance.equals(definition['equals'], `${path}.equals`);\n\t\t}\n\n\t\tif ('integer' in definition) {\n\t\t\tif (!JSON.isBoolean(definition['integer']))\n\t\t\t\tthrow new DefinitionError(`Expected ${path}.integer to be a Boolean`);\n\n\t\t\tvalidatorInstance.integer(definition['integer'], `${path}.integer`);\n\t\t}\n\n\t\tif ('min' in definition) {\n\t\t\tif (!JSON.isNumber(definition['min']))\n\t\t\t\tthrow new DefinitionError(`Expected ${path}.min to be a Number`);\n\n\t\t\tvalidatorInstance.min(definition['min'], `${path}.min`);\n\t\t}\n\n\t\tif ('max' in definition) {\n\t\t\tif (!JSON.isNumber(definition['max']))\n\t\t\t\tthrow new DefinitionError(`Expected ${path}.max to be a Number`);\n\n\t\t\tvalidatorInstance.max(definition['max'], `${path}.max`);\n\t\t}\n\n\t\treturn validatorInstance;\n\t}\n\n\tprotected _nullable: Option<null> = Option.None();\n\tprotected _equals: Option<JSON.Number> = Option.None();\n\tprotected _integer: Option<null> = Option.None();\n\tprotected _min: Option<number> = Option.None();\n\tprotected _max: Option<number> = Option.None();\n\n\tpublic nullable<const F extends boolean = true>(flag?: F): NumberValidator<T, F> {\n\t\tthis._nullable = (flag ?? true) ? Option.Some(null) : Option.None();\n\n\t\treturn this as unknown as NumberValidator<T, F>;\n\t}\n\n\tpublic equals<const V extends number>(value: V, path: string = 'equals'): NumberValidator<V, N> {\n\t\tif (this._integer.isSome() && !Number.isSafeInteger(value))\n\t\t\tthrow new DefinitionError(`Expected Equals Rule to be an Integer according to the Integer Rule at Path ${path}`);\n\n\t\tif (this._min.isSome() && this._min.value > value)\n\t\t\tthrow new DefinitionError(`Expected Equals Rule to be larger than or equal to the Minimum Rule at Path ${path}`);\n\n\t\tif (this._max.isSome() && this._max.value < value)\n\t\t\tthrow new DefinitionError(`Expected Equals Rule to be smaller than or equal to the Maximum Rule at Path ${path}`);\n\n\t\tthis._equals = Option.Some(value);\n\n\t\treturn this as unknown as NumberValidator<V, N>;\n\t}\n\n\tpublic integer(flag: boolean = true, path: string = 'integer'): this {\n\t\tif (flag && this._equals.isSome() && !Number.isSafeInteger(this._equals.value))\n\t\t\tthrow new DefinitionError(`Expected Integer Rule to be a false due to the Equals Rule being a Float at Path ${path}`);\n\n\t\tthis._integer = flag ? Option.Some(null) : Option.None();\n\n\t\treturn this;\n\t}\n\n\tpublic min(value: number, path: string = 'min'): this {\n\t\tif (this._max.isSome() && this._max.value < value)\n\t\t\tthrow new DefinitionError(`Expected Minimum Rule to be smaller than or equal to Maximum Rule at Path ${path}`);\n\n\t\tif (this._equals.isSome() && this._equals.value < value)\n\t\t\tthrow new DefinitionError(`Expected Minimum Rule to be smaller than or equal to the Equals Rule at Path ${path}`);\n\n\t\tthis._min = Option.Some(value);\n\n\t\treturn this;\n\t}\n\n\tpublic max(value: number, path: string = 'max'): this {\n\t\tif (this._min.isSome() && this._min.value > value)\n\t\t\tthrow new DefinitionError(`Expected Maximum Rule to be larger than or equal to Minimum Rule at Path ${path}`);\n\n\t\tif (this._equals.isSome() && this._equals.value > value)\n\t\t\tthrow new DefinitionError(`Expected Maximum Rule to be larger than or equal to the Equals Rule at Path ${path}`);\n\n\t\tthis._max = Option.Some(value);\n\n\t\treturn this;\n\t}\n\n\tpublic assert(data: unknown, path: string = 'data'): asserts data is ApplyNullability<T, N> {\n\t\tif (JSON.isNumber(data)) {\n\t\t\tif (this._equals.isSome() && this._equals.value !== data)\n\t\t\t\tthrow new AssertError(`Expected ${path} to be ${this._equals.value}`);\n\n\t\t\tif (this._integer.isSome() && !Number.isInteger(data))\n\t\t\t\tthrow new AssertError(`Expected ${path} to be an Integer`);\n\n\t\t\tif (this._min.isSome() && this._min.value > data)\n\t\t\t\tthrow new AssertError(`Expected ${path} to be at least ${this._min.value}`);\n\n\t\t\tif (this._max.isSome() && this._max.value < data)\n\t\t\t\tthrow new AssertError(`Expected ${path} to be at most ${this._max.value}`);\n\t\t}\n\t\telse if(JSON.isNull(data)) {\n\t\t\tif(!this._nullable.isSome())\n\t\t\t\tthrow new AssertError(`Expected ${path} to be a Number${this._nullable.isSome() ? ' or Null' : ''}`);\n\t\t}\n\t\telse\n\t\t\tthrow new AssertError(`Expected ${path} to be a Number${this._nullable.isSome() ? ' or Null' : ''}`);\n\t}\n\n\tpublic isSubset(other: Validator): boolean {\n\t\tif (other instanceof JSONValidator)\n\t\t\treturn true;\n\n\t\tif (!(other instanceof NumberValidator))\n\t\t\treturn false;\n\n\t\tif (this._nullable.isSome() && !other._nullable.isSome())\n\t\t\treturn false;\n\n\t\tif (this._equals.isSome()) {\n\t\t\tif (other._equals.isSome() && other._equals.value !== this._equals.value)\n\t\t\t\treturn false;\n\n\t\t\tif (other._integer.isSome() && !Number.isInteger(this._equals.value))\n\t\t\t\treturn false;\n\n\t\t\tif (other._min.isSome() && other._min.value > this._equals.value)\n\t\t\t\treturn false;\n\n\t\t\tif (other._max.isSome() && other._max.value < this._equals.value)\n\t\t\t\treturn false;\n\n\t\t\treturn true;\n\t\t}\n\n\t\tif (other._equals.isSome())\n\t\t\treturn false;\n\n\t\tif (!this._integer.isSome() && other._integer.isSome())\n\t\t\treturn false;\n\n\t\tif (other._min.isSome() && (!this._min.isSome() || this._min.value < other._min.value))\n\t\t\treturn false;\n\n\t\tif (other._max.isSome() && (!this._max.isSome() || this._max.value > other._max.value))\n\t\t\treturn false;\n\n\t\treturn true;\n\t}\n\n\tpublic toJSON(): NumberValidatorDefinition {\n\t\tconst definition: NumberValidatorDefinition = {\n\t\t\ttype: 'number'\n\t\t};\n\n\t\tif (this._nullable.isSome())\n\t\t\tdefinition['nullable'] = true;\n\n\t\tif (this._equals.isSome())\n\t\t\tdefinition['equals'] = this._equals.value;\n\n\t\tif (this._integer.isSome())\n\t\t\tdefinition['integer'] = true;\n\n\t\tif (this._min.isSome())\n\t\t\tdefinition['min'] = this._min.value;\n\n\t\tif (this._max.isSome())\n\t\t\tdefinition['max'] = this._max.value;\n\n\t\treturn definition;\n\t}\n}", "import {JSON} from '@serum-enterprises/json';\nimport {Option} from '@serum-enterprises/option';\nimport {Validator} from '../Validator';\nimport {Definition, ApplyNullability, AssertError, DefinitionError} from '../lib/util';\nimport {JSONValidator} from './JSON';\n\nexport interface StringValidatorDefinition extends Definition {\n\ttype: 'string';\n\tnullable?: boolean;\n\tequals?: JSON.String;\n\tmin?: number;\n\tmax?: number;\n}\n\nexport class StringValidator<\n\tT extends JSON.String = JSON.String,\n\tN extends boolean = false\n> extends Validator<ApplyNullability<T, N>> {\n\tpublic static fromJSON(\n\t\tdefinition: Definition & { [key: string]: unknown },\n\t\tpath: string = 'schema'\n\t): Validator {\n\t\tconst validatorInstance = new StringValidator();\n\n\t\tif ('nullable' in definition) {\n\t\t\tif (!JSON.isBoolean(definition['nullable']))\n\t\t\t\tthrow new DefinitionError(`Expected ${path}.nullable to be a Boolean`);\n\n\t\t\tvalidatorInstance.nullable(definition['nullable']);\n\t\t}\n\n\t\tif ('equals' in definition) {\n\t\t\tif (!JSON.isString(definition['equals']))\n\t\t\t\tthrow new DefinitionError(`Expected ${path}.equals to be a String`);\n\n\t\t\tvalidatorInstance.equals(definition['equals'], `${path}.equals`);\n\t\t}\n\n\t\tif ('min' in definition) {\n\t\t\tif (!JSON.isNumber(definition['min']))\n\t\t\t\tthrow new DefinitionError(`Expected ${path}.min to be a positive Integer`);\n\n\t\t\tvalidatorInstance.min(definition['min'], `${path}.min`);\n\t\t}\n\n\t\tif ('max' in definition) {\n\t\t\tif (!JSON.isNumber(definition['max']))\n\t\t\t\tthrow new DefinitionError(`Expected ${path}.max to be a positive Integer`);\n\n\t\t\tvalidatorInstance.max(definition['max'], `${path}.max`);\n\t\t}\n\n\t\treturn validatorInstance;\n\t}\n\n\tprotected _nullable: Option<null> = Option.None();\n\tprotected _equals: Option<JSON.String> = Option.None();\n\tprotected _min: Option<number> = Option.None();\n\tprotected _max: Option<number> = Option.None();\n\n\tpublic nullable<const F extends boolean = true>(flag?: F): StringValidator<T, F> {\n\t\tthis._nullable = (flag ?? true) ? Option.Some(null) : Option.None();\n\n\t\treturn this as unknown as StringValidator<T, F>;\n\t}\n\n\tpublic equals<const V extends string>(value: V, path: string = 'equals'): StringValidator<V, N> {\n\t\tif (this._min.isSome() && this._min.value > value.length)\n\t\t\tthrow new DefinitionError(`Expected the Equals Rules Length to be larger than or equal to the Minimum Rule at Path ${path}`);\n\n\t\tif (this._max.isSome() && this._max.value < value.length)\n\t\t\tthrow new DefinitionError(`Expected the Equals Rules Length to be smaller than or equal to the Maximum Rule at Path ${path}`);\n\n\n\t\tthis._equals = Option.Some(value);\n\n\t\treturn this as unknown as StringValidator<V, N>;\n\t}\n\n\tpublic min(value: number, path: string = 'min'): this {\n\t\tif (!Number.isSafeInteger(value) || value < 0)\n\t\t\tthrow new DefinitionError(`Expected ${path}.min to be a positive Integer`);\n\n\t\tif (this._max.isSome() && this._max.value < value)\n\t\t\tthrow new DefinitionError(`Expected Minimum Rule to be smaller than or equal to Maximum Rule at Path ${path}`);\n\n\t\tif (this._equals.isSome() && this._equals.value.length < value)\n\t\t\tthrow new DefinitionError(`Expected Minimum Rule to be smaller than or equal to the Equals Rules Length at Path ${path}`);\n\n\t\tthis._min = Option.Some(value);\n\n\t\treturn this;\n\t}\n\n\tpublic max(value: number, path: string = 'max'): this {\n\t\tif (!Number.isSafeInteger(value) || value < 0)\n\t\t\tthrow new DefinitionError(`Expected ${path}.max to be a positive Integer`);\n\n\t\tif (this._min.isSome() && this._min.value > value)\n\t\t\tthrow new DefinitionError(`Expected Maximum Rule to be larger than or equal to Minimum Rule at Path ${path}`);\n\n\t\tif (this._equals.isSome() && this._equals.value.length > value)\n\t\t\tthrow new DefinitionError(`Expected Maximum Rule to be larger than or equal to the Equals Rules Length at Path ${path}`);\n\n\t\tthis._max = Option.Some(value);\n\n\t\treturn this;\n\t}\n\n\tpublic assert(data: unknown, path: string = 'data'): asserts data is ApplyNullability<T, N> {\n\t\tif (JSON.isString(data)) {\n\t\t\tif (this._equals.isSome() && this._equals.value !== data)\n\t\t\t\tthrow new AssertError(`Expected ${path} to be ${this._equals.value}`);\n\n\t\t\tif (this._min.isSome() && this._min.value > data.length)\n\t\t\t\tthrow new AssertError(`Expected ${path} to be at least ${this._min.value} characters long`);\n\n\t\t\tif (this._max.isSome() && this._max.value < data.length)\n\t\t\t\tthrow new AssertError(`Expected ${path} to be at most ${this._max.value} characters long`);\n\t\t}\n\t\telse if(JSON.isNull(data)) {\n\t\t\tif(!this._nullable.isSome())\n\t\t\t\tthrow new AssertError(`Expected ${path} to be a String${this._nullable.isSome() ? ' or Null' : ''}`);\n\t\t}\n\t\telse\n\t\t\tthrow new AssertError(`Expected ${path} to be a String${this._nullable.isSome() ? ' or Null' : ''}`);\n\t}\n\n\tpublic isSubset(other: Validator): boolean {\n\t\tif (other instanceof JSONValidator)\n\t\t\treturn true;\n\n\t\tif (!(other instanceof StringValidator))\n\t\t\treturn false;\n\n\t\tif (this._nullable.isSome() && !other._nullable.isSome())\n\t\t\treturn false;\n\n\t\tif (this._equals.isSome()) {\n\t\t\tif (other._equals.isSome() && other._equals.value !== this._equals.value)\n\t\t\t\treturn false;\n\n\t\t\tif (other._min.isSome() && other._min.value > this._equals.value.length)\n\t\t\t\treturn false;\n\n\t\t\tif (other._max.isSome() && other._max.value < this._equals.value.length)\n\t\t\t\treturn false;\n\n\t\t\treturn true;\n\t\t}\n\n\t\tif (other._equals.isSome())\n\t\t\treturn false;\n\n\t\tif (other._min.isSome() && (!this._min.isSome() || this._min.value < other._min.value))\n\t\t\treturn false;\n\n\t\tif (other._max.isSome() && (!this._max.isSome() || this._max.value > other._max.value))\n\t\t\treturn false;\n\n\t\treturn true;\n\t}\n\n\tpublic toJSON(): StringValidatorDefinition {\n\t\tconst definition: StringValidatorDefinition = {\n\t\t\ttype: 'string'\n\t\t};\n\n\t\tif (this._nullable.isSome())\n\t\t\tdefinition['nullable'] = true;\n\n\t\tif (this._equals.isSome())\n\t\t\tdefinition['equals'] = this._equals.value;\n\n\t\tif (this._min.isSome())\n\t\t\tdefinition['min'] = this._min.value;\n\n\t\tif (this._max.isSome())\n\t\t\tdefinition['max'] = this._max.value;\n\n\t\treturn definition;\n\t}\n}", "import {JSON} from '@serum-enterprises/json';\nimport {Option} from '@serum-enterprises/option';\nimport {Validator} from '../Validator';\nimport {fromJSON} from '../lib/fromJSON';\nimport {\n\tDefinition, ApplyNullability,\n\tInferDefinitionType, InferValidatorReturnType,\n\tInferListDefinitionType, InferListReturnType,\n\tAssertError, DefinitionError\n} from '../lib/util';\nimport {JSONValidator} from './JSON';\n\ntype ArrayResult<E, T> =\n\tT extends readonly unknown[]\n\t\t? [...{ [K in keyof T]: T[K] & E }, ...E[]]\n\t\t: E[];\n\nexport interface ArrayValidatorDefinition<\n\tE extends Definition = Definition,\n\tT extends readonly Definition[] = readonly Definition[]\n> extends Definition {\n\ttype: 'array';\n\tnullable?: boolean;\n\tmin?: number;\n\tmax?: number;\n\tevery?: E;\n\ttuple?: T;\n}\n\nexport class ArrayValidator<\n\t// E & T are the Every and Tuple Return Types\n\tE = unknown,\n\tT = unknown,\n\t// EV & TV are the Every and Tuple Definitions\n\tED extends Definition = Definition,\n\tTD extends readonly Definition[] = readonly Definition[],\n\t// N is the Nullable Flag\n\tN extends boolean = false\n> extends Validator<ApplyNullability<ArrayResult<E, T>, N>> {\n\tpublic static fromJSON(\n\t\tdefinition: Definition & { [key: string]: unknown },\n\t\tpath: string = 'definition'\n\t): Validator {\n\t\tconst validatorInstance = new ArrayValidator();\n\n\t\tif ('nullable' in definition) {\n\t\t\tif (!JSON.isBoolean(definition['nullable']))\n\t\t\t\tthrow new DefinitionError(`Expected ${path}.nullable to be a Boolean`);\n\n\t\t\tvalidatorInstance.nullable(definition['nullable']);\n\t\t}\n\n\t\tif ('min' in definition) {\n\t\t\tif (!JSON.isNumber(definition['min']))\n\t\t\t\tthrow new DefinitionError(`Expected ${path}.min to be a Number`);\n\n\t\t\tvalidatorInstance.min(definition['min'], `${path}.min`);\n\t\t}\n\n\t\tif ('max' in definition) {\n\t\t\tif (!JSON.isNumber(definition['max']))\n\t\t\t\tthrow new DefinitionError(`Expected ${path}.max to be a Number`);\n\n\t\t\tvalidatorInstance.max(definition['max'], `${path}.max`);\n\t\t}\n\n\t\tif ('every' in definition) {\n\t\t\tif (!JSON.isObject(definition['every']))\n\t\t\t\tthrow new DefinitionError(`Expected ${path}.every to be an Object`);\n\n\t\t\tvalidatorInstance.every(\n\t\t\t\tfromJSON(definition['every'], `${path}.every`) as Validator\n\t\t\t);\n\t\t}\n\n\t\tif ('tuple' in definition) {\n\t\t\tif (!JSON.isShallowArray(definition['tuple']))\n\t\t\t\tthrow new DefinitionError(`Expected ${path}.tuple to be an Array`);\n\n\t\t\tconst tupleSchemas: Validator[] = [];\n\t\t\tconst errors: DefinitionError[] = [];\n\n\t\t\tdefinition['tuple'].forEach((tupleDef, index) => {\n\t\t\t\ttry {\n\t\t\t\t\ttupleSchemas.push(fromJSON(tupleDef, `${path}.tuple[${index}]`));\n\t\t\t\t} catch (e) {\n\t\t\t\t\tif (!(e instanceof DefinitionError))\n\t\t\t\t\t\tthrow new DefinitionError(`Fatal Error: Undefined Error thrown by Domain.fromJSON at ${path}`);\n\n\t\t\t\t\terrors.push(e);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tif (errors.length > 0)\n\t\t\t\tthrow new DefinitionError(`Multiple Definition Errors detected at ${path} (see cause)`, {cause: errors});\n\n\t\t\tvalidatorInstance.tuple(tupleSchemas, `${path}.tuple`);\n\t\t}\n\n\t\treturn validatorInstance;\n\t}\n\n\tprotected _nullable: Option<null> = Option.None();\n\tprotected _every: Option<Validator> = Option.None();\n\tprotected _tuple: Option<readonly Validator[]> = Option.None();\n\tprotected _min: Option<number> = Option.None();\n\tprotected _max: Option<number> = Option.None();\n\n\tpublic nullable<const F extends boolean = true>(flag?: F): ArrayValidator<E, T, ED, TD, F> {\n\t\tthis._nullable = (flag ?? true) ? Option.Some(null) : Option.None();\n\n\t\treturn this as unknown as ArrayValidator<E, T, ED, TD, F>;\n\t}\n\n\tpublic min(value: number, path: string = 'min'): this {\n\t\tif (this._max.isSome() && this._max.value < value)\n\t\t\tthrow new DefinitionError(`Expected Minimum Rule to be smaller than or equal to Maximum Rule at Path ${path}`);\n\n\t\tif (this._tuple.isSome() && value < this._tuple.value.length)\n\t\t\tthrow new DefinitionError(`Expected Minimum Rule to be larger than or equal to Tuple Length at Path ${path}`);\n\n\t\tthis._min = Option.Some(value);\n\n\t\treturn this;\n\t}\n\n\tpublic max(value: number, path: string = 'max'): this {\n\t\tif (this._min.isSome() && this._min.value > value)\n\t\t\tthrow new DefinitionError(`Expected Maximum Rule to be larger than or equal to Minimum Rule at Path ${path}`);\n\n\t\tif (this._tuple.isSome() && value < this._tuple.value.length)\n\t\t\tthrow new DefinitionError(`Expected Maximum Rule to be larger than or equal to Tuple Length at Path ${path}`);\n\n\t\tthis._max = Option.Some(value);\n\n\t\treturn this;\n\t}\n\n\tpublic every<const V extends Validator>(validator: V): ArrayValidator<\n\t\tInferValidatorReturnType<V>,\n\t\tT,\n\t\tInferDefinitionType<V>,\n\t\tTD,\n\t\tN\n\t> {\n\t\tthis._every = Option.Some(validator);\n\n\t\treturn this as unknown as ArrayValidator<InferValidatorReturnType<V>, T, InferDefinitionType<V>, TD, N>;\n\t}\n\n\t/**\n\t * Applies ONLY to prefix indices [0..validators.length - 1]\n\t * If every() is set, prefix elements are effectively `T[i] & E`.\n\t */\n\tpublic tuple<const V extends readonly Validator[]>(\n\t\tvalidators: V,\n\t\tpath: string = 'tuple'\n\t): ArrayValidator<\n\t\tE,\n\t\tInferListReturnType<V>,\n\t\tED,\n\t\tInferListDefinitionType<V>,\n\t\tN\n\t> {\n\t\tif (this._min.isSome() && this._min.value < validators.length)\n\t\t\tthrow new DefinitionError(`Expected Tuple Length to be smaller than or equal to Minimum Rule at Path ${path}`);\n\n\t\tif (this._max.isSome() && this._max.value < validators.length)\n\t\t\tthrow new DefinitionError(`Expected Tuple Length to be smaller than or equal to Maximum Rule at Path ${path}`);\n\n\t\tthis._tuple = Option.Some(validators);\n\n\t\treturn this as unknown as ArrayValidator<E, InferListReturnType<V>, ED, InferListDefinitionType<V>, N>;\n\t}\n\n\tpublic assert(\n\t\tdata: unknown,\n\t\tpath: string = 'data'\n\t): asserts data is ApplyNullability<ArrayResult<E, T>, N> {\n\t\tif (JSON.isShallowArray(data)) {\n\t\t\tif (this._min.isSome() && this._min.value > data.length)\n\t\t\t\tthrow new AssertError(`Expected ${path} to be at least ${this._min.value} Elements long`);\n\n\t\t\tif (this._max.isSome() && this._max.value < data.length)\n\t\t\t\tthrow new AssertError(`Expected ${path} to be at most ${this._max.value} Elements long`);\n\n\t\t\tconst errors: AssertError[] = [];\n\n\t\t\tif (this._every.isSome()) {\n\t\t\t\tconst validator: Validator = this._every.value;\n\n\t\t\t\tdata.forEach((value, index) => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tvalidator.assert(value, `${path}[${index}]`);\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\tif (!(e instanceof AssertError))\n\t\t\t\t\t\t\tthrow new AssertError(`Fatal Error: Undefined Error thrown by an Assert Method at ${path}[${index}]`);\n\n\t\t\t\t\t\terrors.push(e);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (this._tuple.isSome()) {\n\t\t\t\tif (data.length < this._tuple.value.length)\n\t\t\t\t\tthrow new AssertError(`Expected ${path} to be at least ${this._tuple.value.length} Elements long (Tuple Constraint)`);\n\n\t\t\t\tthis._tuple.value.forEach((validator: Validator, index) => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tvalidator.assert(data[index], `${path}[${index}]`);\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\tif (!(e instanceof AssertError))\n\t\t\t\t\t\t\tthrow new AssertError(`Fatal Error: Undefined Error thrown by an Assert Method at ${path}[${index}]`);\n\n\t\t\t\t\t\terrors.push(e);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (errors.length > 0)\n\t\t\t\tthrow new AssertError(`Multiple Errors while asserting ${path} (see cause)`, {cause: errors});\n\t\t}\n\t\telse if(JSON.isNull(data)) {\n\t\t\tif(!this._nullable.isSome())\n\t\t\t\tthrow new AssertError(`Expected ${path} to be an Array${this._nullable.isSome() ? ' or Null' : ''}`);\n\t\t}\n\t\telse\n\t\t\tthrow new AssertError(`Expected ${path} to be an Array${this._nullable.isSome() ? ' or Null' : ''}`);\n\t}\n\n\tpublic isSubset(other: Validator): boolean {\n\t\tif(other instanceof JSONValidator)\n\t\t\treturn true;\n\n\t\tif (!(other instanceof ArrayValidator))\n\t\t\treturn false;\n\n\t\tif (this._nullable.isSome() && !other._nullable.isSome())\n\t\t\treturn false;\n\n\t\tconst thisTupleLen = this._tuple.isSome() ? this._tuple.value.length : 0;\n\t\tconst otherTupleLen = other._tuple.isSome() ? other._tuple.value.length : 0;\n\n\t\tconst thisMin = this._min.isSome() ? this._min.value : 0;\n\t\tconst otherMin = other._min.isSome() ? other._min.value : 0;\n\n\t\tconst thisMax = this._max.isSome() ? this._max.value : Infinity;\n\t\tconst otherMax = other._max.isSome() ? other._max.value : Infinity;\n\n\t\tconst thisEffectiveMin = Math.max(thisMin, thisTupleLen);\n\t\tconst otherEffectiveMin = Math.max(otherMin, otherTupleLen);\n\n\t\tif (thisEffectiveMin < otherEffectiveMin)\n\t\t\treturn false;\n\n\t\tif (thisMax > otherMax)\n\t\t\treturn false;\n\n\t\t// Helper: this index constraints are the intersection of (every, tuple[i])\n\t\t// To soundly prove (A_every \u2229 A_tuple[i]) \u2286 Target, it's sufficient that\n\t\t// at least one conjunct is itself a subset of Target (false negatives allowed).\n\t\tconst indexConjuncts = (i: number): Validator[] => {\n\t\t\tconst conjuncts: Validator[] = [];\n\n\t\t\tif (this._every.isSome())\n\t\t\t\tconjuncts.push(this._every.value);\n\n\t\t\tif (this._tuple.isSome() && i < this._tuple.value.length)\n\t\t\t\tconjuncts.push(this._tuple.value[i]!);\n\n\t\t\treturn conjuncts;\n\t\t};\n\n\t\tconst conjunctsSubset = (conjuncts: Validator[], target: Validator): boolean => {\n\t\t\t// If we have no constraint at all, we accept \"anything\" at that position,\n\t\t\t// so we can only be a subset if the target also accepts anything \u2014 we\n\t\t\t// cannot prove that here, so be conservative.\n\t\t\tif (conjuncts.length === 0)\n\t\t\t\treturn false;\n\n\t\t\treturn conjuncts.some(c => c.isSubset(target));\n\t\t};\n\n\t\tif (other._tuple.isSome()) {\n\t\t\tfor (let i = 0; i < other._tuple.value.length; i++) {\n\t\t\t\tconst aConj = indexConjuncts(i);\n\n\t\t\t\tif (!conjunctsSubset(aConj, other._tuple.value[i]!))\n\t\t\t\t\treturn false;\n\n\t\t\t\tif (other._every.isSome() && !conjunctsSubset(aConj, other._every.value))\n\t\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn !(other._every.isSome() && (thisMax === Infinity ? true : thisMax > Math.max(thisTupleLen, otherTupleLen)) && (!this._every.isSome() || !this._every.value.isSubset(other._every.value)));\n\t}\n\n\tpublic toJSON(): ArrayValidatorDefinition<ED, TD> {\n\t\tconst definition: ArrayValidatorDefinition = {type: 'array'};\n\n\t\tif (this._nullable.isSome())\n\t\t\tdefinition.nullable = true;\n\n\t\tif (this._min.isSome())\n\t\t\tdefinition.min = this._min.value;\n\n\t\tif (this._max.isSome())\n\t\t\tdefinition.max = this._max.value;\n\n\t\tif (this._every.isSome())\n\t\t\tdefinition.every = this._every.value.toJSON();\n\n\t\tif (this._tuple.isSome())\n\t\t\tdefinition.tuple = this._tuple.value.map(validator => validator.toJSON());\n\n\t\treturn definition as ArrayValidatorDefinition<ED, TD>;\n\t}\n}", "import {JSON} from '@serum-enterprises/json';\nimport {Option} from '@serum-enterprises/option';\nimport {Validator} from '../Validator';\nimport {fromJSON} from '../lib/fromJSON';\nimport {\n\tDefinition, ApplyNullability,\n\tInferDefinitionType, InferValidatorReturnType,\n\tInferObjectDefinitionType, InferObjectReturnType,\n\tAssertError, DefinitionError\n} from '../lib/util';\nimport {JSONValidator} from './JSON';\n\ntype ObjectResult<T, S, E extends boolean> =\n\tS extends { [key: string]: unknown }\n\t\t? E extends true\n\t\t\t? { [K in keyof S]: S[K] & T }\n\t\t\t: { [K in keyof S]: S[K] & T } & { [key: string]: T }\n\t\t: { [key: string]: T };\n\nexport interface ObjectValidatorDefinition<\n\tTD extends Definition = Definition,\n\tSD extends { [key: string]: Definition } = { [key: string]: Definition }\n> extends Definition {\n\ttype: 'object';\n\tnullable?: boolean;\n\texact?: boolean;\n\tmin?: number;\n\tmax?: number;\n\tevery?: TD;\n\tshape?: SD;\n}\n\nexport class ObjectValidator<\n\t// T & S are the Every (Type) and Shape return types\n\tT = unknown,\n\tS = unknown,\n\t// TD & SD are the Every (Type) and Shape definitions\n\tTD extends Definition = Definition,\n\tSD extends { [key: string]: Definition } = { [key: string]: Definition },\n\t// N is nullable\n\tN extends boolean = false,\n\t// E is exact (no extra props when shape is set)\n\tE extends boolean = false\n> extends Validator<ObjectResult<T, S, E>> {\n\tpublic static fromJSON(\n\t\tdefinition: Definition & { [key: string]: unknown },\n\t\tpath: string = \"definition\"\n\t): Validator {\n\t\tconst validatorInstance = new ObjectValidator();\n\n\t\tif (\"nullable\" in definition) {\n\t\t\tif (!JSON.isBoolean(definition[\"nullable\"]))\n\t\t\t\tthrow new DefinitionError(`Expected ${path}.nullable to be a Boolean`);\n\n\t\t\tvalidatorInstance.nullable(definition[\"nullable\"]);\n\t\t}\n\n\t\tif (\"exact\" in definition) {\n\t\t\tif (!JSON.isBoolean(definition[\"exact\"]))\n\t\t\t\tthrow new DefinitionError(`Expected ${path}.exact to be a Boolean`);\n\n\t\t\tvalidatorInstance.exact(definition[\"exact\"], `${path}.exact`);\n\t\t}\n\n\t\tif (\"min\" in definition) {\n\t\t\tif (!JSON.isNumber(definition[\"min\"]))\n\t\t\t\tthrow new DefinitionError(`Expected ${path}.min to be a Number`);\n\n\t\t\tvalidatorInstance.min(definition[\"min\"], `${path}.min`);\n\t\t}\n\n\t\tif (\"max\" in definition) {\n\t\t\tif (!JSON.isNumber(definition[\"max\"]))\n\t\t\t\tthrow new DefinitionError(`Expected ${path}.max to be a Number`);\n\n\t\t\tvalidatorInstance.max(definition[\"max\"], `${path}.max`);\n\t\t}\n\n\t\tif (\"every\" in definition) {\n\t\t\tvalidatorInstance.every(fromJSON(definition['every'], `${path}.every`));\n\t\t}\n\n\t\tif (\"shape\" in definition) {\n\t\t\tif (!JSON.isShallowObject(definition[\"shape\"]))\n\t\t\t\tthrow new DefinitionError(`Expected ${path}.shape to be an Object`);\n\n\t\t\tconst shape: { [key: string]: Validator } = {};\n\t\t\tconst errors: DefinitionError[] = [];\n\n\t\t\tfor (const [key, value] of Object.entries(definition[\"shape\"])) {\n\t\t\t\ttry {\n\t\t\t\t\tshape[key] = fromJSON(value, `${path}.shape.${key}`);\n\t\t\t\t} catch (e) {\n\t\t\t\t\tif (!(e instanceof DefinitionError))\n\t\t\t\t\t\tthrow new DefinitionError(`Fatal Error: Undefined Error thrown by Domain.fromJSON at ${path}.shape.${key}`);\n\n\t\t\t\t\terrors.push(e);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (errors.length > 0) {\n\t\t\t\tthrow new DefinitionError(`Multiple Definition Errors detected at ${path}.shape (see cause)`, {cause: errors});\n\t\t\t}\n\n\t\t\tvalidatorInstance.shape(shape, `${path}.shape`);\n\t\t}\n\n\t\treturn validatorInstance;\n\t}\n\n\tprotected _nullable: Option<null> = Option.None();\n\tprotected _min: Option<number> = Option.None();\n\tprotected _max: Option<number> = Option.None();\n\tprotected _every: Option<Validator> = Option.None();\n\tprotected _shape: Option<{ [key: string]: Validator }> = Option.None();\n\tprotected _exact: Option<null> = Option.None();\n\n\n\tpublic nullable<const F extends boolean = true>(flag?: F): ObjectValidator<T, S, TD, SD, F, E> {\n\t\tthis._nullable = (flag ?? true) ? Option.Some(null) : Option.None();\n\n\t\treturn this as unknown as ObjectValidator<T, S, TD, SD, F, E>;\n\t}\n\n\tpublic min(value: number, path: string = 'min'): this {\n\t\tif (this._max.isSome() && this._max.value < value)\n\t\t\tthrow new DefinitionError(`Expected Minimum Rule to be smaller than or equal to Maximum Rule at Path ${path}`);\n\n\t\tif (this._shape.isSome() && value < Object.keys(this._shape.value).length)\n\t\t\tthrow new DefinitionError(`Expected Minimum Rule to be larger than or equal to Shape Key Count at Path ${path}`);\n\n\t\tif (this._exact.isSome() && this._shape.isSome() && value > Object.keys(this._shape.value).length)\n\t\t\tthrow new DefinitionError(`Expected Minimum Rule to be smaller than or equal to Shape Key Count due to Exact Rule at Path ${path}`);\n\n\t\tthis._min = Option.Some(value);\n\n\t\treturn this;\n\t}\n\n\tpublic max(value: number, path: string = 'max'): this {\n\t\tif (this._min.isSome() && this._min.value > value)\n\t\t\tthrow new DefinitionError(`Expected Maximum Rule to be larger than or equal to Minimum Rule at Path ${path}`);\n\n\t\tif (this._shape.isSome() && value < Object.keys(this._shape.value).length)\n\t\t\tthrow new DefinitionError(`Expected Maximum Rule to be larger than or equal to Shape Key Count at Path ${path}`);\n\n\t\tthis._max = Option.Some(value);\n\n\t\treturn this;\n\t}\n\n\tpublic every<V extends Validator>(validator: V): ObjectValidator<\n\t\tInferValidatorReturnType<V>,\n\t\tS,\n\t\tInferDefinitionType<V>,\n\t\tSD,\n\t\tN,\n\t\tE\n\t> {\n\t\tthis._every = Option.Some(validator);\n\n\t\treturn this as unknown as ObjectValidator<InferValidatorReturnType<V>, S, InferDefinitionType<V>, SD, N, E>;\n\t}\n\n\tpublic shape<S extends { [key: string]: Validator }>(value: S, path: string = 'shape'): ObjectValidator<\n\t\tT,\n\t\tInferObjectReturnType<S>,\n\t\tTD,\n\t\tInferObjectDefinitionType<S>,\n\t\tN,\n\t\tE\n\t> {\n\t\tconst shapeKeyCount = Object.keys(value).length;\n\n\t\tif (this._min.isSome() && this._min.value < shapeKeyCount)\n\t\t\tthrow new DefinitionError(`Expected Shape Key Count to be smaller than or equal to Minimum Rule at Path ${path}`);\n\n\t\tif (this._max.isSome() && this._max.value < shapeKeyCount)\n\t\t\tthrow new DefinitionError(`Expected Shape Key Count to be smaller than or equal to Maximum Rule at Path ${path}`);\n\n\t\tif (this._exact.isSome() && this._min.isSome() && this._min.value > shapeKeyCount)\n\t\t\tthrow new DefinitionError(`Expected Shape Key Count to be larger than or equal to Minimum Rule due to Exact Rule at Path ${path}`);\n\n\t\tif (this._exact.isSome() && this._max.isSome() && this._max.value < shapeKeyCount)\n\t\t\tthrow new DefinitionError(`Expected Shape Key Count to be smaller than or equal to Maximum Rule due to Exact Rule at Path ${path}`);\n\n\t\tthis._shape = Option.Some(value);\n\n\t\treturn this as unknown as ObjectValidator<T, InferObjectReturnType<S>, TD, InferObjectDefinitionType<S>, N, E>;\n\t}\n\n\tpublic exact<const F extends boolean = true>(flag?: F, path: string = 'exact'): ObjectValidator<T, S, TD, SD, N, F> {\n\t\tif ((flag ?? true) && this._shape.isSome()) {\n\t\t\tconst shapeKeyCount = Object.keys(this._shape.value).length;\n\n\t\t\tif (this._min.isSome() && this._min.value > shapeKeyCount)\n\t\t\t\tthrow new DefinitionError(`Expected Exact Rule to be false due to Minimum Rule requiring more Properties than Shape defines at Path ${path}`);\n\n\t\t\tif (this._max.isSome() && this._max.value < shapeKeyCount)\n\t\t\t\tthrow new DefinitionError(`Expected Exact Rule to be false due to Maximum Rule allowing fewer Properties than Shape defines at Path ${path}`);\n\t\t}\n\n\t\tthis._exact = (flag ?? true) ? Option.Some(null) : Option.None();\n\n\t\treturn this as unknown as ObjectValidator<T, S, TD, SD, N, F>;\n\t}\n\n\tpublic assert(data: unknown, path: string = \"data\"): asserts data is ApplyNullability<ObjectResult<T, S, E>, N> {\n\t\tif(JSON.isShallowObject(data)) {\n\t\t\tconst keys = Object.keys(data);\n\n\t\t\tif (this._min.isSome() && keys.length < this._min.value)\n\t\t\t\tthrow new AssertError(`Expected ${path} to have at least ${this._min.value} Properties`);\n\n\t\t\tif (this._max.isSome() && keys.length > this._max.value)\n\t\t\t\tthrow new AssertError(`Expected ${path} to have at most ${this._max.value} Properties`);\n\n\t\t\tconst errors: AssertError[] = [];\n\n\t\t\tif (this._shape.isSome()) {\n\t\t\t\tfor (const key of Object.keys(this._shape.value)) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst validator: Validator = this._shape.value[key]!;\n\n\t\t\t\t\t\tvalidator.assert(data[key], `${path}.${key}`);\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\tif (!(e instanceof AssertError))\n\t\t\t\t\t\t\tthrow new AssertError(`Fatal Error: Undefined Error thrown by an Assert Method at ${path}.${key}`);\n\n\t\t\t\t\t\terrors.push(e);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (this._exact.isSome()) {\n\t\t\t\t\tfor (const key of keys) {\n\t\t\t\t\t\tif (!(key in this._shape.value)) {\n\t\t\t\t\t\t\terrors.push(new AssertError(`Unexpected property ${path}.${key}`));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (this._every.isSome()) {\n\t\t\t\tconst validator: Validator = this._every.value;\n\n\t\t\t\tfor (const key of keys) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tvalidator.assert(data[key], `${path}.${key}`);\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\tif (!(e instanceof AssertError))\n\t\t\t\t\t\t\tthrow new AssertError(`Fatal Error: Undefined Error thrown by an Assert Method at ${path}.${key}`);\n\n\t\t\t\t\t\terrors.push(e);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (errors.length > 0)\n\t\t\t\tthrow new AssertError(`Multiple Errors while asserting ${path} (see cause)`, {cause: errors});\n\t\t}\n\t\telse if(JSON.isNull(data)) {\n\t\t\tif(!this._nullable.isSome())\n\t\t\t\tthrow new AssertError(`Expected ${path} to be an Object${this._nullable.isSome() ? ' or Null' : ''}`);\n\t\t}\n\t\telse\n\t\t\tthrow new AssertError(`Expected ${path} to be an Object${this._nullable.isSome() ? ' or Null' : ''}`);\n\t}\n\n\tpublic isSubset(other: Validator): boolean {\n\t\tif(other instanceof JSONValidator)\n\t\t\treturn true;\n\n\t\t// Must be the same validator type\n\t\tif (!(other instanceof ObjectValidator))\n\t\t\treturn false;\n\n\t\t// ---- 1) Nullability ----\n\t\t// If this allows null, the other must allow null as well\n\t\tif (this._nullable.isSome() && !other._nullable.isSome())\n\t\t\treturn false;\n\n\t\t// ---- 2) Min / Max (property count) ----\n\t\t// For subset: this must be at least as strict as other.\n\t\tconst thisMin = this._min.isSome() ? this._min.value : 0;\n\t\tconst otherMin = other._min.isSome() ? other._min.value : 0;\n\t\tif (thisMin < otherMin)\n\t\t\treturn false;\n\n\t\tconst thisMax = this._max.isSome() ? this._max.value : Number.POSITIVE_INFINITY;\n\t\tconst otherMax = other._max.isSome() ? other._max.value : Number.POSITIVE_INFINITY;\n\t\tif (thisMax > otherMax)\n\t\t\treturn false;\n\n\t\t// ---- 3) Shape requirements ----\n\t\t// If other requires certain keys (shape), this must also require them, and be compatible per key.\n\t\tif (other._shape.isSome()) {\n\t\t\tif (!this._shape.isSome())\n\t\t\t\treturn false;\n\n\t\t\tconst thisShape = this._shape.value;\n\t\t\tconst otherShape = other._shape.value;\n\n\t\t\tfor (const key of Object.keys(otherShape)) {\n\t\t\t\tif (!(key in thisShape))\n\t\t\t\t\treturn false;\n\n\t\t\t\tconst a = thisShape[key]!;\n\t\t\t\tconst b = otherShape[key]!;\n\t\t\t\tif (!a.isSubset(b))\n\t\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\t// ---- 4) Exactness ----\n\t\t// If other is exact, then this must be exact AND must have the exact same key set as other.shape.\n\t\tif (other._exact.isSome()) {\n\t\t\tif (!this._exact.isSome())\n\t\t\t\treturn false;\n\n\t\t\tif (!other._shape.isSome() || !this._shape.isSome())\n\t\t\t\treturn false;\n\n\t\t\tconst aKeys = Object.keys(this._shape.value).sort();\n\t\t\tconst bKeys = Object.keys(other._shape.value).sort();\n\n\t\t\tif (aKeys.length !== bKeys.length)\n\t\t\t\treturn false;\n\n\t\t\tfor (let i = 0; i < aKeys.length; i++) {\n\t\t\t\tif (aKeys[i] !== bKeys[i])\n\t\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\t// ---- 5) \"every\" constraint ----\n\t\t// If other has an \"every\" constraint, all values in any object accepted by this must satisfy it.\n\t\tif (other._every.isSome()) {\n\t\t\tconst bEvery = other._every.value;\n\n\t\t\t// All *possible* properties accepted by this must be constrained to bEvery.\n\t\t\t// If this can accept arbitrary keys (not exact), then we need this.every \u2286 bEvery.\n\t\t\tif (!this._exact.isSome()) {\n\t\t\t\tif (!this._every.isSome())\n\t\t\t\t\treturn false;\n\n\t\t\t\tif (!this._every.value.isSubset(bEvery))\n\t\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Additionally, any explicitly shaped properties must also imply bEvery.\n\t\t\t// (Even if this.every exists, shape validators might allow values outside bEvery.)\n\t\t\tif (this._shape.isSome()) {\n\t\t\t\tfor (const [_, v] of Object.entries(this._shape.value)) {\n\t\t\t\t\tif (!v.isSubset(bEvery))\n\t\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// If this is exact and has a shape, then there are no unknown keys;\n\t\t\t// the per-shape check above is sufficient (and this.every is optional).\n\t\t\tif (this._exact.isSome() && !this._shape.isSome()) {\n\t\t\t\t// Exact without shape is effectively meaningless for bounding keys,\n\t\t\t\t// so conservatively require this.every in that case.\n\t\t\t\tif (!this._every.isSome())\n\t\t\t\t\treturn false;\n\n\t\t\t\tif (!this._every.value.isSubset(bEvery))\n\t\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\t// If other has no \"every\", this can be stricter or looser on value-types freely (as long as above holds).\n\n\t\treturn true;\n\t}\n\n\tpublic toJSON(): ObjectValidatorDefinition<TD, SD> {\n\t\tconst schema: ObjectValidatorDefinition = {type: \"object\"};\n\n\t\tif (this._nullable.isSome())\n\t\t\tschema.nullable = true;\n\n\t\tif (this._exact.isSome())\n\t\t\tschema.exact = true;\n\n\t\tif (this._min.isSome())\n\t\t\tschema.min = this._min.value;\n\n\t\tif (this._max.isSome())\n\t\t\tschema.max = this._max.value;\n\n\t\tif (this._every.isSome())\n\t\t\tschema.every = this._every.value.toJSON();\n\n\t\tif (this._shape.isSome()) {\n\t\t\tschema.shape = Object.fromEntries(\n\t\t\t\tObject.entries(this._shape.value).map(([k, s]) => [k, s.toJSON()])\n\t\t\t) as any;\n\t\t}\n\n\t\treturn schema as ObjectValidatorDefinition<TD, SD>;\n\t}\n}"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,wDAAAA,UAAA;AAAA;AACA,WAAO,eAAeA,UAAS,cAAc,EAAE,OAAO,KAAK,CAAC;AAC5D,IAAAA,SAAQ,OAAO;AACf,QAAIC;AACJ,KAAC,SAAUA,OAAM;AACb,e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AAO,SAAS,YAAqB,OAAe,cAAyB;AAC5E,WAAO,SAAS,YAAY,IAAI;AAAA,EACjC;AACD;AAEO,IAAM,aAAa;AAAA,EACzB,MAAM;AAAA,EACN,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,QAAQ;AACT;",
|
|
3
|
+
"sources": ["../node_modules/@serum-enterprises/json/build/index.js", "../node_modules/@serum-enterprises/option/build/Option.js", "../src/index.ts", "../src/Validator.ts", "../src/lib/fromJSON.ts", "../src/validators/JSON.ts", "../src/lib/util.ts", "../src/validators/Boolean.ts", "../src/validators/Number.ts", "../src/validators/String.ts", "../src/validators/Array.ts", "../src/validators/Object.ts", "../src/lib/isEquals.ts"],
|
|
4
|
+
"sourcesContent": ["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.JSON = void 0;\nvar JSON;\n(function (JSON) {\n function isNull(value) {\n return value === null;\n }\n JSON.isNull = isNull;\n function isBoolean(value) {\n return typeof value === 'boolean';\n }\n JSON.isBoolean = isBoolean;\n function isNumber(value) {\n // Using Number.isFinite here as NaN, Infinity and -Infinity are not valid JSON Numbers\n return Number.isFinite(value);\n }\n JSON.isNumber = isNumber;\n function isInteger(value) {\n // Using Number.isSafeInteger here as JS Numbers are 64-bit floating point numbers and not all integers can be represented accurately\n return Number.isSafeInteger(value);\n }\n JSON.isInteger = isInteger;\n function isString(value) {\n return typeof value === 'string';\n }\n JSON.isString = isString;\n function isShallowArray(value) {\n return Array.isArray(value);\n }\n JSON.isShallowArray = isShallowArray;\n function isArray(value) {\n return isShallowArray(value) && value.every((v) => isJSON(v));\n }\n JSON.isArray = isArray;\n function isShallowObject(value) {\n // Using Object.prototype.toString.call here as it is the most reliable way to check if something is an Object\n return (Object.prototype.toString.call(value) === '[object Object]');\n }\n JSON.isShallowObject = isShallowObject;\n function isObject(value) {\n return isShallowObject(value) && Object.values(value).every((v) => isJSON(v));\n }\n JSON.isObject = isObject;\n function isPrimitive(value) {\n return isBoolean(value) || isNumber(value) || isString(value);\n }\n JSON.isPrimitive = isPrimitive;\n function isShallowContainer(value) {\n return isShallowArray(value) || isShallowObject(value);\n }\n JSON.isShallowContainer = isShallowContainer;\n function isContainer(value) {\n return isArray(value) || isObject(value);\n }\n JSON.isContainer = isContainer;\n function isShallowJSON(value) {\n return isNull(value) || isPrimitive(value) || isShallowArray(value) || isShallowObject(value);\n }\n JSON.isShallowJSON = isShallowJSON;\n function isJSON(value) {\n return isNull(value) || isPrimitive(value) || isContainer(value);\n }\n JSON.isJSON = isJSON;\n function clone(value) {\n // Using Shallow Checks here as it is expected that value is JSON anyway, and this function is recursive anyway\n if (isShallowObject(value))\n return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, clone(v)]));\n else if (isShallowArray(value))\n return value.map((v) => clone(v));\n else\n return value;\n }\n JSON.clone = clone;\n // Compatibility Method for the native JSON.parse\n function parse(value) {\n return globalThis.JSON.parse(value);\n }\n JSON.parse = parse;\n // Compatibility Method for the native JSON.stringify\n function stringify(value) {\n return globalThis.JSON.stringify(value);\n }\n JSON.stringify = stringify;\n})(JSON || (exports.JSON = JSON = {}));\n", "\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.None = exports.Some = exports.Option = void 0;\nclass Option {\n static Some(value) {\n return new Some(value);\n }\n static None() {\n return new None();\n }\n isSome() {\n return this instanceof Some;\n }\n isNone() {\n return this instanceof None;\n }\n onSome(fn) {\n if (this.isSome())\n fn(this.value);\n return this;\n }\n onNone(fn) {\n if (this.isNone())\n fn();\n return this;\n }\n map(fn) {\n return this.match(value => Option.Some(fn(value)), () => Option.None());\n }\n match(onSome, onNone) {\n if (this.isSome())\n return onSome(this.value);\n else\n return onNone();\n }\n}\nexports.Option = Option;\nclass Some extends Option {\n _value;\n constructor(value) {\n super();\n this._value = value;\n }\n get value() {\n return this._value;\n }\n}\nexports.Some = Some;\nclass None extends Option {\n}\nexports.None = None;\n", "import {Validator} from './Validator';\nimport {fromJSON} from './lib/fromJSON';\nimport {isEquals} from \"./lib/isEquals\";\n\nexport {Validator};\n\nimport {JSONValidator, JSONValidatorDefinition} from './validators/JSON';\nimport {BooleanValidator, BooleanValidatorDefinition} from './validators/Boolean';\nimport {NumberValidator, NumberValidatorDefinition} from './validators/Number';\nimport {StringValidator, StringValidatorDefinition} from './validators/String';\nimport {ArrayValidator, ArrayValidatorDefinition} from './validators/Array';\nimport {ObjectValidator, ObjectValidatorDefinition} from './validators/Object';\n\nexport class Schema {\n\tstatic get JSON(): JSONValidator {\n\t\treturn new JSONValidator();\n\t}\n\n\tstatic get Boolean(): BooleanValidator {\n\t\treturn new BooleanValidator();\n\t}\n\n\tstatic get Number(): NumberValidator {\n\t\treturn new NumberValidator();\n\t}\n\n\tstatic get String(): StringValidator {\n\t\treturn new StringValidator();\n\t}\n\n\tstatic get Array(): ArrayValidator {\n\t\treturn new ArrayValidator();\n\t}\n\n\tstatic get Object(): ObjectValidator {\n\t\treturn new ObjectValidator();\n\t}\n\n\tstatic fromJSON(definition: unknown, path: string = 'definition'): Validator {\n\t\treturn fromJSON(definition, path);\n\t}\n\n\tstatic isEquals(a: Validator, b: Validator): boolean {\n\t\treturn isEquals(a, b);\n\t}\n}\n\nexport const Validators = {\n\tJSON: JSONValidator,\n\tBoolean: BooleanValidator,\n\tNumber: NumberValidator,\n\tString: StringValidator,\n\tArray: ArrayValidator,\n\tObject: ObjectValidator\n} as const;\n\nexport type Definition =\n\tJSONValidatorDefinition |\n\tBooleanValidatorDefinition |\n\tNumberValidatorDefinition |\n\tStringValidatorDefinition |\n\tArrayValidatorDefinition |\n\tObjectValidatorDefinition;\n\nexport namespace Definitions {\n\texport type JSON = JSONValidatorDefinition;\n\texport type Boolean = BooleanValidatorDefinition;\n\texport type Number = NumberValidatorDefinition;\n\texport type String = StringValidatorDefinition;\n\texport type Array = ArrayValidatorDefinition;\n\texport type Object = ObjectValidatorDefinition;\n}\n\nexport {InferDefinitionType, InferValidatorReturnType} from './lib/util';", "import {Definition} from './lib/util';\n\nexport abstract class Validator<T = unknown> {\n\tpublic abstract assert(data: unknown, path: string): asserts data is T;\n\tpublic abstract isSubset(other: Validator): boolean;\n\tpublic abstract isEquals(other: Validator): boolean;\n\n\tpublic validate(data: unknown, path: string = 'data'): T {\n\t\tthis.assert(data, path);\n\n\t\treturn data;\n\t}\n\n\tpublic is(data: unknown, path: string = 'data'): data is T {\n\t\ttry {\n\t\t\tthis.assert(data, path);\n\t\t\treturn true;\n\t\t} catch (e) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tpublic abstract toJSON(): Definition;\n}", "import {JSON} from '@serum-enterprises/json';\nimport type {Validator} from '../Validator';\nimport {JSONValidator} from '../validators/JSON';\nimport {BooleanValidator} from '../validators/Boolean';\nimport {NumberValidator} from '../validators/Number';\nimport {StringValidator} from '../validators/String';\nimport {ArrayValidator} from '../validators/Array';\nimport {ObjectValidator} from '../validators/Object';\nimport {Definition, DefinitionError} from './util';\n\nexport function fromJSON(\n\tdefinition: unknown,\n\tpath: string\n): Validator {\n\tif (!JSON.isShallowObject(definition))\n\t\tthrow new DefinitionError(`Expected ${path} to be an Object`);\n\n\tif (!JSON.isString(definition['type']))\n\t\tthrow new DefinitionError(`Expected ${path}.type to be a String`);\n\n\tswitch(definition['type']) {\n\t\tcase 'json':\n\t\t\treturn JSONValidator.fromJSON(definition as Definition & {[key: string]: unknown}, path);\n\t\tcase 'boolean':\n\t\t\treturn BooleanValidator.fromJSON(definition as Definition & {[key: string]: unknown}, path);\n\t\tcase 'number':\n\t\t\treturn NumberValidator.fromJSON(definition as Definition & {[key: string]: unknown}, path);\n\t\tcase 'string':\n\t\t\treturn StringValidator.fromJSON(definition as Definition & {[key: string]: unknown}, path);\n\t\tcase 'array':\n\t\t\treturn ArrayValidator.fromJSON(definition as Definition & {[key: string]: unknown}, path);\n\t\tcase 'object':\n\t\t\treturn ObjectValidator.fromJSON(definition as Definition & {[key: string]: unknown}, path);\n\t\tdefault:\n\t\t\tthrow new DefinitionError(`Expected ${path}.type to be a registered Validator`);\n\t}\n}", "import {JSON} from '@serum-enterprises/json';\nimport {Validator} from '../Validator';\nimport {Definition, AssertError} from '../lib/util';\n\nexport interface JSONValidatorDefinition extends Definition {\n\ttype: 'json';\n}\n\nexport class JSONValidator<T extends JSON.JSON = JSON.JSON> extends Validator<T> {\n\tpublic static fromJSON(\n\t\t_definition: Definition & { [key: string]: unknown },\n\t\t_path: string = 'definition'\n\t): Validator {\n\t\treturn new JSONValidator();\n\t}\n\n\tpublic assert(data: unknown, path: string = 'data'): asserts data is JSON.JSON {\n\t\tif (!JSON.isJSON(data))\n\t\t\tthrow new AssertError(`Expected ${path} to be valid JSON`);\n\t}\n\n\tpublic isSubset(other: Validator): boolean {\n\t\treturn other instanceof JSONValidator;\n\t}\n\n\tpublic isEquals(other: Validator): boolean {\n\t\treturn other instanceof JSONValidator;\n\t}\n\n\tpublic toJSON(): JSONValidatorDefinition {\n\t\treturn {\n\t\t\ttype: 'json'\n\t\t};\n\t}\n}", "import type {Validator} from '../Validator';\n\nexport type ApplyNullability<T, N extends boolean> =\n\tN extends true ? T | null : Exclude<T, null>;\n\nexport interface Definition {\n\ttype: string;\n}\n\nexport type InferDefinitionType<V> = V extends { toJSON(): infer D } ? D : never;\nexport type InferValidatorReturnType<V> = V extends Validator<infer T> ? T : unknown;\n\nexport type InferListDefinitionType<T extends readonly Validator[]> = {\n\t[K in keyof T]: InferDefinitionType<T[K]>;\n};\nexport type InferListReturnType<T> = T extends readonly Validator[] ?\n\t{ [K in keyof T]: InferValidatorReturnType<T[K]> } :\n\tunknown;\n\nexport type InferObjectDefinitionType<T extends { [key: string]: Validator }> = {\n\t[K in keyof T]: InferDefinitionType<T[K]>\n}\nexport type InferObjectReturnType<T> = T extends { [key: string]: Validator } ?\n\t{ [K in keyof T]: InferValidatorReturnType<T[K]> } :\n\tunknown;\n\nexport class AssertError extends Error {}\n\nexport class DefinitionError extends Error {}", "import {JSON} from '@serum-enterprises/json';\nimport {Option} from '@serum-enterprises/option';\nimport {Validator} from '../Validator';\nimport {Definition, ApplyNullability, AssertError, DefinitionError} from '../lib/util';\nimport {JSONValidator} from './JSON';\n\nexport interface BooleanValidatorDefinition extends Definition {\n\ttype: 'boolean';\n\tnullable?: boolean;\n\tequals?: boolean;\n}\n\nexport class BooleanValidator<\n\tT extends JSON.Boolean = JSON.Boolean,\n\tN extends boolean = false\n> extends Validator<ApplyNullability<T, N>> {\n\tpublic static fromJSON(\n\t\tdefinition: Definition & { [key: string]: unknown },\n\t\tpath: string = 'definition'\n\t): Validator {\n\t\tconst validatorInstance = new BooleanValidator();\n\n\t\tif ('nullable' in definition) {\n\t\t\tif (!JSON.isBoolean(definition['nullable']))\n\t\t\t\tthrow new DefinitionError(`Expected ${path}.nullable to be a Boolean`);\n\n\t\t\tvalidatorInstance.nullable(definition['nullable']);\n\t\t}\n\n\t\tif ('equals' in definition) {\n\t\t\tif (!JSON.isBoolean(definition['equals']))\n\t\t\t\tthrow new DefinitionError(`Expected ${path}.equals to be a Boolean`);\n\n\t\t\tvalidatorInstance.equals(definition['equals']);\n\t\t}\n\n\t\treturn validatorInstance;\n\t}\n\n\tprotected _nullable: Option<null> = Option.None();\n\tprotected _equals: Option<boolean> = Option.None();\n\n\tpublic nullable<const F extends boolean = true>(flag?: F): BooleanValidator<T, F> {\n\t\tthis._nullable = flag ?? true ? Option.Some(null) : Option.None();\n\n\t\treturn this as unknown as BooleanValidator<T, F>;\n\t}\n\n\tpublic equals<const V extends boolean>(value: V): BooleanValidator<V, N> {\n\t\tthis._equals = Option.Some(value);\n\n\t\treturn this as unknown as BooleanValidator<V, N>;\n\t}\n\n\tpublic assert(data: unknown, path: string = 'data'): asserts data is ApplyNullability<T, N> {\n\t\tif (JSON.isBoolean(data)) {\n\t\t\tif (this._equals.isSome() && this._equals.value !== data)\n\t\t\t\tthrow new AssertError(`Expected ${path} to be ${this._equals.value}${this._nullable.isSome() ? '' : ' or Null'}`);\n\t\t}\n\t\telse if(JSON.isNull(data)) {\n\t\t\tif(!this._nullable.isSome())\n\t\t\t\tthrow new AssertError(`Expected ${path} to be a Boolean${this._nullable.isSome() ? ' or Null' : ''}`);\n\t\t}\n\t\telse\n\t\t\tthrow new AssertError(`Expected ${path} to be a Boolean${this._nullable.isSome() ? ' or Null' : ''}`);\n\t}\n\n\tpublic isSubset(other: Validator): boolean {\n\t\tif (other instanceof JSONValidator)\n\t\t\treturn true;\n\n\t\tif (!(other instanceof BooleanValidator))\n\t\t\treturn false;\n\n\t\tif (this._nullable.isSome() && !other._nullable.isSome())\n\t\t\treturn false;\n\n\t\tif (other._equals.isSome()) {\n\t\t\tif (this._equals.isSome())\n\t\t\t\treturn this._equals.value === other._equals.value;\n\t\t\telse\n\t\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tpublic override isEquals(other: Validator): boolean {\n\t\tif (!(other instanceof BooleanValidator))\n\t\t\treturn false;\n\n\t\tif (this._nullable.isSome() !== other._nullable.isSome())\n\t\t\treturn false;\n\n\t\tif (this._equals.isSome() !== other._equals.isSome())\n\t\t\treturn false;\n\n\t\tif (this._equals.isSome() && other._equals.isSome() && this._equals.value !== other._equals.value)\n\t\t\treturn false;\n\n\t\treturn true;\n\t}\n\n\tpublic toJSON(): BooleanValidatorDefinition {\n\t\tconst definition: BooleanValidatorDefinition = {\n\t\t\ttype: 'boolean'\n\t\t};\n\n\t\tif (this._nullable.isSome())\n\t\t\tdefinition['nullable'] = true;\n\n\t\tif (this._equals.isSome())\n\t\t\tdefinition['equals'] = this._equals.value;\n\n\t\treturn definition;\n\t}\n}", "import {JSON} from '@serum-enterprises/json';\nimport {Option} from '@serum-enterprises/option';\nimport {Validator} from '../Validator';\nimport {Definition, ApplyNullability, AssertError, DefinitionError} from '../lib/util';\nimport {JSONValidator} from './JSON';\n\nexport interface NumberValidatorDefinition extends Definition {\n\ttype: 'number';\n\tnullable?: boolean;\n\tequals?: JSON.Number;\n\tinteger?: boolean;\n\tmin?: number;\n\tmax?: number;\n}\n\nexport class NumberValidator<\n\tT extends JSON.Number = JSON.Number,\n\tN extends boolean = false\n> extends Validator<ApplyNullability<T, N>> {\n\tpublic static fromJSON(\n\t\tdefinition: Definition & { [key: string]: unknown },\n\t\tpath: string = 'definition'\n\t): Validator {\n\t\tconst validatorInstance = new NumberValidator();\n\n\t\tif ('nullable' in definition) {\n\t\t\tif (!JSON.isBoolean(definition['nullable']))\n\t\t\t\tthrow new DefinitionError(`Expected ${path}.nullable to be a Boolean`);\n\n\t\t\tvalidatorInstance.nullable(definition['nullable']);\n\t\t}\n\n\t\tif ('equals' in definition) {\n\t\t\tif (!JSON.isNumber(definition['equals']))\n\t\t\t\tthrow new DefinitionError(`Expected ${path}.equals to be a Number`);\n\n\t\t\tvalidatorInstance.equals(definition['equals'], `${path}.equals`);\n\t\t}\n\n\t\tif ('integer' in definition) {\n\t\t\tif (!JSON.isBoolean(definition['integer']))\n\t\t\t\tthrow new DefinitionError(`Expected ${path}.integer to be a Boolean`);\n\n\t\t\tvalidatorInstance.integer(definition['integer'], `${path}.integer`);\n\t\t}\n\n\t\tif ('min' in definition) {\n\t\t\tif (!JSON.isNumber(definition['min']))\n\t\t\t\tthrow new DefinitionError(`Expected ${path}.min to be a Number`);\n\n\t\t\tvalidatorInstance.min(definition['min'], `${path}.min`);\n\t\t}\n\n\t\tif ('max' in definition) {\n\t\t\tif (!JSON.isNumber(definition['max']))\n\t\t\t\tthrow new DefinitionError(`Expected ${path}.max to be a Number`);\n\n\t\t\tvalidatorInstance.max(definition['max'], `${path}.max`);\n\t\t}\n\n\t\treturn validatorInstance;\n\t}\n\n\tprotected _nullable: Option<null> = Option.None();\n\tprotected _equals: Option<JSON.Number> = Option.None();\n\tprotected _integer: Option<null> = Option.None();\n\tprotected _min: Option<number> = Option.None();\n\tprotected _max: Option<number> = Option.None();\n\n\tpublic nullable<const F extends boolean = true>(flag?: F): NumberValidator<T, F> {\n\t\tthis._nullable = (flag ?? true) ? Option.Some(null) : Option.None();\n\n\t\treturn this as unknown as NumberValidator<T, F>;\n\t}\n\n\tpublic equals<const V extends number>(value: V, path: string = 'equals'): NumberValidator<V, N> {\n\t\tif (this._integer.isSome() && !Number.isSafeInteger(value))\n\t\t\tthrow new DefinitionError(`Expected Equals Rule to be an Integer according to the Integer Rule at Path ${path}`);\n\n\t\tif (this._min.isSome() && this._min.value > value)\n\t\t\tthrow new DefinitionError(`Expected Equals Rule to be larger than or equal to the Minimum Rule at Path ${path}`);\n\n\t\tif (this._max.isSome() && this._max.value < value)\n\t\t\tthrow new DefinitionError(`Expected Equals Rule to be smaller than or equal to the Maximum Rule at Path ${path}`);\n\n\t\tthis._equals = Option.Some(value);\n\n\t\treturn this as unknown as NumberValidator<V, N>;\n\t}\n\n\tpublic integer(flag: boolean = true, path: string = 'integer'): this {\n\t\tif (flag && this._equals.isSome() && !Number.isSafeInteger(this._equals.value))\n\t\t\tthrow new DefinitionError(`Expected Integer Rule to be a false due to the Equals Rule being a Float at Path ${path}`);\n\n\t\tthis._integer = flag ? Option.Some(null) : Option.None();\n\n\t\treturn this;\n\t}\n\n\tpublic min(value: number, path: string = 'min'): this {\n\t\tif (this._max.isSome() && this._max.value < value)\n\t\t\tthrow new DefinitionError(`Expected Minimum Rule to be smaller than or equal to Maximum Rule at Path ${path}`);\n\n\t\tif (this._equals.isSome() && this._equals.value < value)\n\t\t\tthrow new DefinitionError(`Expected Minimum Rule to be smaller than or equal to the Equals Rule at Path ${path}`);\n\n\t\tthis._min = Option.Some(value);\n\n\t\treturn this;\n\t}\n\n\tpublic max(value: number, path: string = 'max'): this {\n\t\tif (this._min.isSome() && this._min.value > value)\n\t\t\tthrow new DefinitionError(`Expected Maximum Rule to be larger than or equal to Minimum Rule at Path ${path}`);\n\n\t\tif (this._equals.isSome() && this._equals.value > value)\n\t\t\tthrow new DefinitionError(`Expected Maximum Rule to be larger than or equal to the Equals Rule at Path ${path}`);\n\n\t\tthis._max = Option.Some(value);\n\n\t\treturn this;\n\t}\n\n\tpublic assert(data: unknown, path: string = 'data'): asserts data is ApplyNullability<T, N> {\n\t\tif (JSON.isNumber(data)) {\n\t\t\tif (this._equals.isSome() && this._equals.value !== data)\n\t\t\t\tthrow new AssertError(`Expected ${path} to be ${this._equals.value}`);\n\n\t\t\tif (this._integer.isSome() && !Number.isInteger(data))\n\t\t\t\tthrow new AssertError(`Expected ${path} to be an Integer`);\n\n\t\t\tif (this._min.isSome() && this._min.value > data)\n\t\t\t\tthrow new AssertError(`Expected ${path} to be at least ${this._min.value}`);\n\n\t\t\tif (this._max.isSome() && this._max.value < data)\n\t\t\t\tthrow new AssertError(`Expected ${path} to be at most ${this._max.value}`);\n\t\t}\n\t\telse if(JSON.isNull(data)) {\n\t\t\tif(!this._nullable.isSome())\n\t\t\t\tthrow new AssertError(`Expected ${path} to be a Number${this._nullable.isSome() ? ' or Null' : ''}`);\n\t\t}\n\t\telse\n\t\t\tthrow new AssertError(`Expected ${path} to be a Number${this._nullable.isSome() ? ' or Null' : ''}`);\n\t}\n\n\tpublic isSubset(other: Validator): boolean {\n\t\tif (other instanceof JSONValidator)\n\t\t\treturn true;\n\n\t\tif (!(other instanceof NumberValidator))\n\t\t\treturn false;\n\n\t\tif (this._nullable.isSome() && !other._nullable.isSome())\n\t\t\treturn false;\n\n\t\tif (this._equals.isSome()) {\n\t\t\tif (other._equals.isSome() && other._equals.value !== this._equals.value)\n\t\t\t\treturn false;\n\n\t\t\tif (other._integer.isSome() && !Number.isInteger(this._equals.value))\n\t\t\t\treturn false;\n\n\t\t\tif (other._min.isSome() && other._min.value > this._equals.value)\n\t\t\t\treturn false;\n\n\t\t\tif (other._max.isSome() && other._max.value < this._equals.value)\n\t\t\t\treturn false;\n\n\t\t\treturn true;\n\t\t}\n\n\t\tif (other._equals.isSome())\n\t\t\treturn false;\n\n\t\tif (!this._integer.isSome() && other._integer.isSome())\n\t\t\treturn false;\n\n\t\tif (other._min.isSome() && (!this._min.isSome() || this._min.value < other._min.value))\n\t\t\treturn false;\n\n\t\tif (other._max.isSome() && (!this._max.isSome() || this._max.value > other._max.value))\n\t\t\treturn false;\n\n\t\treturn true;\n\t}\n\n\tpublic isEquals(other: Validator): boolean {\n\t\tif(!(other instanceof NumberValidator))\n\t\t\treturn false;\n\n\t\tif (this._nullable.isSome() !== other._nullable.isSome())\n\t\t\treturn false;\n\n\t\tif (this._integer.isSome() !== other._integer.isSome())\n\t\t\treturn false;\n\n\t\tif (this._equals.isSome() !== other._equals.isSome())\n\t\t\treturn false;\n\n\t\tif (this._equals.isSome() && other._equals.isSome() && this._equals.value !== other._equals.value)\n\t\t\treturn false;\n\n\t\tif (this._min.isSome() !== other._min.isSome())\n\t\t\treturn false;\n\n\t\tif (this._min.isSome() && other._min.isSome() && this._min.value !== other._min.value)\n\t\t\treturn false;\n\n\t\tif (this._max.isSome() !== other._max.isSome())\n\t\t\treturn false;\n\n\t\tif (this._max.isSome() && other._max.isSome() && this._max.value !== other._max.value)\n\t\t\treturn false;\n\n\t\treturn true;\n\t}\n\n\tpublic toJSON(): NumberValidatorDefinition {\n\t\tconst definition: NumberValidatorDefinition = {\n\t\t\ttype: 'number'\n\t\t};\n\n\t\tif (this._nullable.isSome())\n\t\t\tdefinition['nullable'] = true;\n\n\t\tif (this._equals.isSome())\n\t\t\tdefinition['equals'] = this._equals.value;\n\n\t\tif (this._integer.isSome())\n\t\t\tdefinition['integer'] = true;\n\n\t\tif (this._min.isSome())\n\t\t\tdefinition['min'] = this._min.value;\n\n\t\tif (this._max.isSome())\n\t\t\tdefinition['max'] = this._max.value;\n\n\t\treturn definition;\n\t}\n}", "import {JSON} from '@serum-enterprises/json';\nimport {Option} from '@serum-enterprises/option';\nimport {Validator} from '../Validator';\nimport {Definition, ApplyNullability, AssertError, DefinitionError} from '../lib/util';\nimport {JSONValidator} from './JSON';\n\nexport interface StringValidatorDefinition extends Definition {\n\ttype: 'string';\n\tnullable?: boolean;\n\tequals?: JSON.String;\n\tmin?: number;\n\tmax?: number;\n}\n\nexport class StringValidator<\n\tT extends JSON.String = JSON.String,\n\tN extends boolean = false\n> extends Validator<ApplyNullability<T, N>> {\n\tpublic static fromJSON(\n\t\tdefinition: Definition & { [key: string]: unknown },\n\t\tpath: string = 'schema'\n\t): Validator {\n\t\tconst validatorInstance = new StringValidator();\n\n\t\tif ('nullable' in definition) {\n\t\t\tif (!JSON.isBoolean(definition['nullable']))\n\t\t\t\tthrow new DefinitionError(`Expected ${path}.nullable to be a Boolean`);\n\n\t\t\tvalidatorInstance.nullable(definition['nullable']);\n\t\t}\n\n\t\tif ('equals' in definition) {\n\t\t\tif (!JSON.isString(definition['equals']))\n\t\t\t\tthrow new DefinitionError(`Expected ${path}.equals to be a String`);\n\n\t\t\tvalidatorInstance.equals(definition['equals'], `${path}.equals`);\n\t\t}\n\n\t\tif ('min' in definition) {\n\t\t\tif (!JSON.isNumber(definition['min']))\n\t\t\t\tthrow new DefinitionError(`Expected ${path}.min to be a positive Integer`);\n\n\t\t\tvalidatorInstance.min(definition['min'], `${path}.min`);\n\t\t}\n\n\t\tif ('max' in definition) {\n\t\t\tif (!JSON.isNumber(definition['max']))\n\t\t\t\tthrow new DefinitionError(`Expected ${path}.max to be a positive Integer`);\n\n\t\t\tvalidatorInstance.max(definition['max'], `${path}.max`);\n\t\t}\n\n\t\treturn validatorInstance;\n\t}\n\n\tprotected _nullable: Option<null> = Option.None();\n\tprotected _equals: Option<JSON.String> = Option.None();\n\tprotected _min: Option<number> = Option.None();\n\tprotected _max: Option<number> = Option.None();\n\n\tpublic nullable<const F extends boolean = true>(flag?: F): StringValidator<T, F> {\n\t\tthis._nullable = (flag ?? true) ? Option.Some(null) : Option.None();\n\n\t\treturn this as unknown as StringValidator<T, F>;\n\t}\n\n\tpublic equals<const V extends string>(value: V, path: string = 'equals'): StringValidator<V, N> {\n\t\tif (this._min.isSome() && this._min.value > value.length)\n\t\t\tthrow new DefinitionError(`Expected the Equals Rules Length to be larger than or equal to the Minimum Rule at Path ${path}`);\n\n\t\tif (this._max.isSome() && this._max.value < value.length)\n\t\t\tthrow new DefinitionError(`Expected the Equals Rules Length to be smaller than or equal to the Maximum Rule at Path ${path}`);\n\n\n\t\tthis._equals = Option.Some(value);\n\n\t\treturn this as unknown as StringValidator<V, N>;\n\t}\n\n\tpublic min(value: number, path: string = 'min'): this {\n\t\tif (!Number.isSafeInteger(value) || value < 0)\n\t\t\tthrow new DefinitionError(`Expected ${path}.min to be a positive Integer`);\n\n\t\tif (this._max.isSome() && this._max.value < value)\n\t\t\tthrow new DefinitionError(`Expected Minimum Rule to be smaller than or equal to Maximum Rule at Path ${path}`);\n\n\t\tif (this._equals.isSome() && this._equals.value.length < value)\n\t\t\tthrow new DefinitionError(`Expected Minimum Rule to be smaller than or equal to the Equals Rules Length at Path ${path}`);\n\n\t\tthis._min = Option.Some(value);\n\n\t\treturn this;\n\t}\n\n\tpublic max(value: number, path: string = 'max'): this {\n\t\tif (!Number.isSafeInteger(value) || value < 0)\n\t\t\tthrow new DefinitionError(`Expected ${path}.max to be a positive Integer`);\n\n\t\tif (this._min.isSome() && this._min.value > value)\n\t\t\tthrow new DefinitionError(`Expected Maximum Rule to be larger than or equal to Minimum Rule at Path ${path}`);\n\n\t\tif (this._equals.isSome() && this._equals.value.length > value)\n\t\t\tthrow new DefinitionError(`Expected Maximum Rule to be larger than or equal to the Equals Rules Length at Path ${path}`);\n\n\t\tthis._max = Option.Some(value);\n\n\t\treturn this;\n\t}\n\n\tpublic assert(data: unknown, path: string = 'data'): asserts data is ApplyNullability<T, N> {\n\t\tif (JSON.isString(data)) {\n\t\t\tif (this._equals.isSome() && this._equals.value !== data)\n\t\t\t\tthrow new AssertError(`Expected ${path} to be ${this._equals.value}`);\n\n\t\t\tif (this._min.isSome() && this._min.value > data.length)\n\t\t\t\tthrow new AssertError(`Expected ${path} to be at least ${this._min.value} characters long`);\n\n\t\t\tif (this._max.isSome() && this._max.value < data.length)\n\t\t\t\tthrow new AssertError(`Expected ${path} to be at most ${this._max.value} characters long`);\n\t\t}\n\t\telse if(JSON.isNull(data)) {\n\t\t\tif(!this._nullable.isSome())\n\t\t\t\tthrow new AssertError(`Expected ${path} to be a String${this._nullable.isSome() ? ' or Null' : ''}`);\n\t\t}\n\t\telse\n\t\t\tthrow new AssertError(`Expected ${path} to be a String${this._nullable.isSome() ? ' or Null' : ''}`);\n\t}\n\n\tpublic isSubset(other: Validator): boolean {\n\t\tif (other instanceof JSONValidator)\n\t\t\treturn true;\n\n\t\tif (!(other instanceof StringValidator))\n\t\t\treturn false;\n\n\t\tif (this._nullable.isSome() && !other._nullable.isSome())\n\t\t\treturn false;\n\n\t\tif (this._equals.isSome()) {\n\t\t\tif (other._equals.isSome() && other._equals.value !== this._equals.value)\n\t\t\t\treturn false;\n\n\t\t\tif (other._min.isSome() && other._min.value > this._equals.value.length)\n\t\t\t\treturn false;\n\n\t\t\tif (other._max.isSome() && other._max.value < this._equals.value.length)\n\t\t\t\treturn false;\n\n\t\t\treturn true;\n\t\t}\n\n\t\tif (other._equals.isSome())\n\t\t\treturn false;\n\n\t\tif (other._min.isSome() && (!this._min.isSome() || this._min.value < other._min.value))\n\t\t\treturn false;\n\n\t\tif (other._max.isSome() && (!this._max.isSome() || this._max.value > other._max.value))\n\t\t\treturn false;\n\n\t\treturn true;\n\t}\n\n\tpublic isEquals(other: Validator): boolean {\n\t\tif(!(other instanceof StringValidator))\n\t\t\treturn false;\n\n\t\tif (this._nullable.isSome() !== other._nullable.isSome())\n\t\t\treturn false;\n\n\t\tif (this._equals.isSome() !== other._equals.isSome())\n\t\t\treturn false;\n\n\t\tif (this._equals.isSome() && other._equals.isSome() && this._equals.value !== other._equals.value)\n\t\t\treturn false;\n\n\t\tif (this._min.isSome() !== other._min.isSome())\n\t\t\treturn false;\n\n\t\tif (this._min.isSome() && other._min.isSome() && this._min.value !== other._min.value)\n\t\t\treturn false;\n\n\t\tif (this._max.isSome() !== other._max.isSome())\n\t\t\treturn false;\n\n\t\tif (this._max.isSome() && other._max.isSome() && this._max.value !== other._max.value)\n\t\t\treturn false;\n\n\t\treturn true;\n\t}\n\n\tpublic toJSON(): StringValidatorDefinition {\n\t\tconst definition: StringValidatorDefinition = {\n\t\t\ttype: 'string'\n\t\t};\n\n\t\tif (this._nullable.isSome())\n\t\t\tdefinition['nullable'] = true;\n\n\t\tif (this._equals.isSome())\n\t\t\tdefinition['equals'] = this._equals.value;\n\n\t\tif (this._min.isSome())\n\t\t\tdefinition['min'] = this._min.value;\n\n\t\tif (this._max.isSome())\n\t\t\tdefinition['max'] = this._max.value;\n\n\t\treturn definition;\n\t}\n}", "import {JSON} from '@serum-enterprises/json';\nimport {Option} from '@serum-enterprises/option';\nimport {Validator} from '../Validator';\nimport {fromJSON} from '../lib/fromJSON';\nimport {isEquals} from '../lib/isEquals';\nimport {\n\tDefinition, ApplyNullability,\n\tInferDefinitionType, InferValidatorReturnType,\n\tInferListDefinitionType, InferListReturnType,\n\tAssertError, DefinitionError\n} from '../lib/util';\nimport {JSONValidator} from './JSON';\n\ntype ArrayResult<E, T> =\n\tT extends readonly unknown[]\n\t\t? [...{ [K in keyof T]: T[K] & E }, ...E[]]\n\t\t: E[];\n\nexport interface ArrayValidatorDefinition<\n\tE extends Definition = Definition,\n\tT extends readonly Definition[] = readonly Definition[]\n> extends Definition {\n\ttype: 'array';\n\tnullable?: boolean;\n\tmin?: number;\n\tmax?: number;\n\tevery?: E;\n\ttuple?: T;\n}\n\nexport class ArrayValidator<\n\t// E & T are the Every and Tuple Return Types\n\tE = unknown,\n\tT = unknown,\n\t// EV & TV are the Every and Tuple Definitions\n\tED extends Definition = Definition,\n\tTD extends readonly Definition[] = readonly Definition[],\n\t// N is the Nullable Flag\n\tN extends boolean = false\n> extends Validator<ApplyNullability<ArrayResult<E, T>, N>> {\n\tpublic static fromJSON(\n\t\tdefinition: Definition & { [key: string]: unknown },\n\t\tpath: string = 'definition'\n\t): Validator {\n\t\tconst validatorInstance = new ArrayValidator();\n\n\t\tif ('nullable' in definition) {\n\t\t\tif (!JSON.isBoolean(definition['nullable']))\n\t\t\t\tthrow new DefinitionError(`Expected ${path}.nullable to be a Boolean`);\n\n\t\t\tvalidatorInstance.nullable(definition['nullable']);\n\t\t}\n\n\t\tif ('min' in definition) {\n\t\t\tif (!JSON.isNumber(definition['min']))\n\t\t\t\tthrow new DefinitionError(`Expected ${path}.min to be a Number`);\n\n\t\t\tvalidatorInstance.min(definition['min'], `${path}.min`);\n\t\t}\n\n\t\tif ('max' in definition) {\n\t\t\tif (!JSON.isNumber(definition['max']))\n\t\t\t\tthrow new DefinitionError(`Expected ${path}.max to be a Number`);\n\n\t\t\tvalidatorInstance.max(definition['max'], `${path}.max`);\n\t\t}\n\n\t\tif ('every' in definition) {\n\t\t\tif (!JSON.isObject(definition['every']))\n\t\t\t\tthrow new DefinitionError(`Expected ${path}.every to be an Object`);\n\n\t\t\tvalidatorInstance.every(\n\t\t\t\tfromJSON(definition['every'], `${path}.every`) as Validator\n\t\t\t);\n\t\t}\n\n\t\tif ('tuple' in definition) {\n\t\t\tif (!JSON.isShallowArray(definition['tuple']))\n\t\t\t\tthrow new DefinitionError(`Expected ${path}.tuple to be an Array`);\n\n\t\t\tconst tupleSchemas: Validator[] = [];\n\t\t\tconst errors: DefinitionError[] = [];\n\n\t\t\tdefinition['tuple'].forEach((tupleDef, index) => {\n\t\t\t\ttry {\n\t\t\t\t\ttupleSchemas.push(fromJSON(tupleDef, `${path}.tuple[${index}]`));\n\t\t\t\t} catch (e) {\n\t\t\t\t\tif (!(e instanceof DefinitionError))\n\t\t\t\t\t\tthrow new DefinitionError(`Fatal Error: Undefined Error thrown by Domain.fromJSON at ${path}`);\n\n\t\t\t\t\terrors.push(e);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tif (errors.length > 0)\n\t\t\t\tthrow new DefinitionError(`Multiple Definition Errors detected at ${path} (see cause)`, {cause: errors});\n\n\t\t\tvalidatorInstance.tuple(tupleSchemas, `${path}.tuple`);\n\t\t}\n\n\t\treturn validatorInstance;\n\t}\n\n\tprotected _nullable: Option<null> = Option.None();\n\tprotected _every: Option<Validator> = Option.None();\n\tprotected _tuple: Option<readonly Validator[]> = Option.None();\n\tprotected _min: Option<number> = Option.None();\n\tprotected _max: Option<number> = Option.None();\n\n\tpublic nullable<const F extends boolean = true>(flag?: F): ArrayValidator<E, T, ED, TD, F> {\n\t\tthis._nullable = (flag ?? true) ? Option.Some(null) : Option.None();\n\n\t\treturn this as unknown as ArrayValidator<E, T, ED, TD, F>;\n\t}\n\n\tpublic min(value: number, path: string = 'min'): this {\n\t\tif (this._max.isSome() && this._max.value < value)\n\t\t\tthrow new DefinitionError(`Expected Minimum Rule to be smaller than or equal to Maximum Rule at Path ${path}`);\n\n\t\tif (this._tuple.isSome() && value < this._tuple.value.length)\n\t\t\tthrow new DefinitionError(`Expected Minimum Rule to be larger than or equal to Tuple Length at Path ${path}`);\n\n\t\tthis._min = Option.Some(value);\n\n\t\treturn this;\n\t}\n\n\tpublic max(value: number, path: string = 'max'): this {\n\t\tif (this._min.isSome() && this._min.value > value)\n\t\t\tthrow new DefinitionError(`Expected Maximum Rule to be larger than or equal to Minimum Rule at Path ${path}`);\n\n\t\tif (this._tuple.isSome() && value < this._tuple.value.length)\n\t\t\tthrow new DefinitionError(`Expected Maximum Rule to be larger than or equal to Tuple Length at Path ${path}`);\n\n\t\tthis._max = Option.Some(value);\n\n\t\treturn this;\n\t}\n\n\tpublic every<const V extends Validator>(validator: V): ArrayValidator<\n\t\tInferValidatorReturnType<V>,\n\t\tT,\n\t\tInferDefinitionType<V>,\n\t\tTD,\n\t\tN\n\t> {\n\t\tthis._every = Option.Some(validator);\n\n\t\treturn this as unknown as ArrayValidator<InferValidatorReturnType<V>, T, InferDefinitionType<V>, TD, N>;\n\t}\n\n\t/**\n\t * Applies ONLY to prefix indices [0..validators.length - 1]\n\t * If every() is set, prefix elements are effectively `T[i] & E`.\n\t */\n\tpublic tuple<const V extends readonly Validator[]>(\n\t\tvalidators: V,\n\t\tpath: string = 'tuple'\n\t): ArrayValidator<\n\t\tE,\n\t\tInferListReturnType<V>,\n\t\tED,\n\t\tInferListDefinitionType<V>,\n\t\tN\n\t> {\n\t\tif (this._min.isSome() && this._min.value < validators.length)\n\t\t\tthrow new DefinitionError(`Expected Tuple Length to be smaller than or equal to Minimum Rule at Path ${path}`);\n\n\t\tif (this._max.isSome() && this._max.value < validators.length)\n\t\t\tthrow new DefinitionError(`Expected Tuple Length to be smaller than or equal to Maximum Rule at Path ${path}`);\n\n\t\tthis._tuple = Option.Some(validators);\n\n\t\treturn this as unknown as ArrayValidator<E, InferListReturnType<V>, ED, InferListDefinitionType<V>, N>;\n\t}\n\n\tpublic assert(\n\t\tdata: unknown,\n\t\tpath: string = 'data'\n\t): asserts data is ApplyNullability<ArrayResult<E, T>, N> {\n\t\tif (JSON.isShallowArray(data)) {\n\t\t\tif (this._min.isSome() && this._min.value > data.length)\n\t\t\t\tthrow new AssertError(`Expected ${path} to be at least ${this._min.value} Elements long`);\n\n\t\t\tif (this._max.isSome() && this._max.value < data.length)\n\t\t\t\tthrow new AssertError(`Expected ${path} to be at most ${this._max.value} Elements long`);\n\n\t\t\tconst errors: AssertError[] = [];\n\n\t\t\tif (this._every.isSome()) {\n\t\t\t\tconst validator: Validator = this._every.value;\n\n\t\t\t\tdata.forEach((value, index) => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tvalidator.assert(value, `${path}[${index}]`);\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\tif (!(e instanceof AssertError))\n\t\t\t\t\t\t\tthrow new AssertError(`Fatal Error: Undefined Error thrown by an Assert Method at ${path}[${index}]`);\n\n\t\t\t\t\t\terrors.push(e);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (this._tuple.isSome()) {\n\t\t\t\tif (data.length < this._tuple.value.length)\n\t\t\t\t\tthrow new AssertError(`Expected ${path} to be at least ${this._tuple.value.length} Elements long (Tuple Constraint)`);\n\n\t\t\t\tthis._tuple.value.forEach((validator: Validator, index) => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tvalidator.assert(data[index], `${path}[${index}]`);\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\tif (!(e instanceof AssertError))\n\t\t\t\t\t\t\tthrow new AssertError(`Fatal Error: Undefined Error thrown by an Assert Method at ${path}[${index}]`);\n\n\t\t\t\t\t\terrors.push(e);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (errors.length > 0)\n\t\t\t\tthrow new AssertError(`Multiple Errors while asserting ${path} (see cause)`, {cause: errors});\n\t\t}\n\t\telse if (JSON.isNull(data)) {\n\t\t\tif (!this._nullable.isSome())\n\t\t\t\tthrow new AssertError(`Expected ${path} to be an Array${this._nullable.isSome() ? ' or Null' : ''}`);\n\t\t}\n\t\telse\n\t\t\tthrow new AssertError(`Expected ${path} to be an Array${this._nullable.isSome() ? ' or Null' : ''}`);\n\t}\n\n\tpublic isSubset(other: Validator): boolean {\n\t\tif (other instanceof JSONValidator)\n\t\t\treturn true;\n\n\t\tif (!(other instanceof ArrayValidator))\n\t\t\treturn false;\n\n\t\tif (this._nullable.isSome() && !other._nullable.isSome())\n\t\t\treturn false;\n\n\t\tconst thisTupleLen = this._tuple.isSome() ? this._tuple.value.length : 0;\n\t\tconst otherTupleLen = other._tuple.isSome() ? other._tuple.value.length : 0;\n\n\t\tconst thisMin = this._min.isSome() ? this._min.value : 0;\n\t\tconst otherMin = other._min.isSome() ? other._min.value : 0;\n\n\t\tconst thisMax = this._max.isSome() ? this._max.value : Infinity;\n\t\tconst otherMax = other._max.isSome() ? other._max.value : Infinity;\n\n\t\tconst thisEffectiveMin = Math.max(thisMin, thisTupleLen);\n\t\tconst otherEffectiveMin = Math.max(otherMin, otherTupleLen);\n\n\t\tif (thisEffectiveMin < otherEffectiveMin)\n\t\t\treturn false;\n\n\t\tif (thisMax > otherMax)\n\t\t\treturn false;\n\n\t\t// Helper: this index constraints are the intersection of (every, tuple[i])\n\t\t// To soundly prove (A_every \u2229 A_tuple[i]) \u2286 Target, it's sufficient that\n\t\t// at least one conjunct is itself a subset of Target (false negatives allowed).\n\t\tconst indexConjuncts = (i: number): Validator[] => {\n\t\t\tconst conjuncts: Validator[] = [];\n\n\t\t\tif (this._every.isSome())\n\t\t\t\tconjuncts.push(this._every.value);\n\n\t\t\tif (this._tuple.isSome() && i < this._tuple.value.length)\n\t\t\t\tconjuncts.push(this._tuple.value[i]!);\n\n\t\t\treturn conjuncts;\n\t\t};\n\n\t\tconst conjunctsSubset = (conjuncts: Validator[], target: Validator): boolean => {\n\t\t\t// If we have no constraint at all, we accept \"anything\" at that position,\n\t\t\t// so we can only be a subset if the target also accepts anything \u2014 we\n\t\t\t// cannot prove that here, so be conservative.\n\t\t\tif (conjuncts.length === 0)\n\t\t\t\treturn false;\n\n\t\t\treturn conjuncts.some(c => c.isSubset(target));\n\t\t};\n\n\t\tif (other._tuple.isSome()) {\n\t\t\tfor (let i = 0; i < other._tuple.value.length; i++) {\n\t\t\t\tconst aConj = indexConjuncts(i);\n\n\t\t\t\tif (!conjunctsSubset(aConj, other._tuple.value[i]!))\n\t\t\t\t\treturn false;\n\n\t\t\t\tif (other._every.isSome() && !conjunctsSubset(aConj, other._every.value))\n\t\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn !(other._every.isSome() && (thisMax === Infinity ? true : thisMax > Math.max(thisTupleLen, otherTupleLen)) && (!this._every.isSome() || !this._every.value.isSubset(other._every.value)));\n\t}\n\n\tpublic isEquals(other: Validator): boolean {\n\t\tif (!(other instanceof ArrayValidator))\n\t\t\treturn false;\n\n\t\tif (this._nullable.isSome() !== other._nullable.isSome())\n\t\t\treturn false;\n\n\t\tif (this._min.isSome() !== other._min.isSome())\n\t\t\treturn false;\n\n\t\tif (this._min.isSome() && other._min.isSome() && this._min.value !== other._min.value)\n\t\t\treturn false;\n\n\t\tif (this._max.isSome() !== other._max.isSome())\n\t\t\treturn false;\n\n\t\tif (this._max.isSome() && other._max.isSome() && this._max.value !== other._max.value)\n\t\t\treturn false;\n\n\t\tif (this._every.isSome() !== other._every.isSome())\n\t\t\treturn false;\n\n\t\tif (this._every.isSome() && other._every.isSome() && !isEquals(this._every.value, other._every.value))\n\t\t\treturn false;\n\n\t\tif (this._tuple.isSome() !== other._tuple.isSome())\n\t\t\treturn false;\n\n\t\tif (this._tuple.isSome() && other._tuple.isSome()) {\n\t\t\tif(this._tuple.value.length !== other._tuple.value.length)\n\t\t\t\treturn false;\n\n\t\t\tfor(let i = 0; i < this._tuple.value.length; i++) {\n\t\t\t\tif(!isEquals(this._tuple.value[i]!, other._tuple.value[i]!))\n\t\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tpublic toJSON(): ArrayValidatorDefinition<ED, TD> {\n\t\tconst definition: ArrayValidatorDefinition = {type: 'array'};\n\n\t\tif (this._nullable.isSome())\n\t\t\tdefinition.nullable = true;\n\n\t\tif (this._min.isSome())\n\t\t\tdefinition.min = this._min.value;\n\n\t\tif (this._max.isSome())\n\t\t\tdefinition.max = this._max.value;\n\n\t\tif (this._every.isSome())\n\t\t\tdefinition.every = this._every.value.toJSON();\n\n\t\tif (this._tuple.isSome())\n\t\t\tdefinition.tuple = this._tuple.value.map(validator => validator.toJSON());\n\n\t\treturn definition as ArrayValidatorDefinition<ED, TD>;\n\t}\n}", "import {JSON} from '@serum-enterprises/json';\nimport {Option} from '@serum-enterprises/option';\nimport {Validator} from '../Validator';\nimport {fromJSON} from '../lib/fromJSON';\nimport {isEquals} from '../lib/isEquals';\nimport {\n\tDefinition, ApplyNullability,\n\tInferDefinitionType, InferValidatorReturnType,\n\tInferObjectDefinitionType, InferObjectReturnType,\n\tAssertError, DefinitionError\n} from '../lib/util';\nimport {JSONValidator} from './JSON';\n\ntype ObjectResult<T, S, E extends boolean> =\n\tS extends { [key: string]: unknown }\n\t\t? E extends true\n\t\t\t? { [K in keyof S]: S[K] & T }\n\t\t\t: { [K in keyof S]: S[K] & T } & { [key: string]: T }\n\t\t: { [key: string]: T };\n\nexport interface ObjectValidatorDefinition<\n\tTD extends Definition = Definition,\n\tSD extends { [key: string]: Definition } = { [key: string]: Definition }\n> extends Definition {\n\ttype: 'object';\n\tnullable?: boolean;\n\texact?: boolean;\n\tmin?: number;\n\tmax?: number;\n\tevery?: TD;\n\tshape?: SD;\n}\n\nexport class ObjectValidator<\n\t// T & S are the Every (Type) and Shape return types\n\tT = unknown,\n\tS = unknown,\n\t// TD & SD are the Every (Type) and Shape definitions\n\tTD extends Definition = Definition,\n\tSD extends { [key: string]: Definition } = { [key: string]: Definition },\n\t// N is nullable\n\tN extends boolean = false,\n\t// E is exact (no extra props when shape is set)\n\tE extends boolean = false\n> extends Validator<ObjectResult<T, S, E>> {\n\tpublic static fromJSON(\n\t\tdefinition: Definition & { [key: string]: unknown },\n\t\tpath: string = \"definition\"\n\t): Validator {\n\t\tconst validatorInstance = new ObjectValidator();\n\n\t\tif (\"nullable\" in definition) {\n\t\t\tif (!JSON.isBoolean(definition[\"nullable\"]))\n\t\t\t\tthrow new DefinitionError(`Expected ${path}.nullable to be a Boolean`);\n\n\t\t\tvalidatorInstance.nullable(definition[\"nullable\"]);\n\t\t}\n\n\t\tif (\"exact\" in definition) {\n\t\t\tif (!JSON.isBoolean(definition[\"exact\"]))\n\t\t\t\tthrow new DefinitionError(`Expected ${path}.exact to be a Boolean`);\n\n\t\t\tvalidatorInstance.exact(definition[\"exact\"], `${path}.exact`);\n\t\t}\n\n\t\tif (\"min\" in definition) {\n\t\t\tif (!JSON.isNumber(definition[\"min\"]))\n\t\t\t\tthrow new DefinitionError(`Expected ${path}.min to be a Number`);\n\n\t\t\tvalidatorInstance.min(definition[\"min\"], `${path}.min`);\n\t\t}\n\n\t\tif (\"max\" in definition) {\n\t\t\tif (!JSON.isNumber(definition[\"max\"]))\n\t\t\t\tthrow new DefinitionError(`Expected ${path}.max to be a Number`);\n\n\t\t\tvalidatorInstance.max(definition[\"max\"], `${path}.max`);\n\t\t}\n\n\t\tif (\"every\" in definition) {\n\t\t\tvalidatorInstance.every(fromJSON(definition['every'], `${path}.every`));\n\t\t}\n\n\t\tif (\"shape\" in definition) {\n\t\t\tif (!JSON.isShallowObject(definition[\"shape\"]))\n\t\t\t\tthrow new DefinitionError(`Expected ${path}.shape to be an Object`);\n\n\t\t\tconst shape: { [key: string]: Validator } = {};\n\t\t\tconst errors: DefinitionError[] = [];\n\n\t\t\tfor (const [key, value] of Object.entries(definition[\"shape\"])) {\n\t\t\t\ttry {\n\t\t\t\t\tshape[key] = fromJSON(value, `${path}.shape.${key}`);\n\t\t\t\t} catch (e) {\n\t\t\t\t\tif (!(e instanceof DefinitionError))\n\t\t\t\t\t\tthrow new DefinitionError(`Fatal Error: Undefined Error thrown by Domain.fromJSON at ${path}.shape.${key}`);\n\n\t\t\t\t\terrors.push(e);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (errors.length > 0) {\n\t\t\t\tthrow new DefinitionError(`Multiple Definition Errors detected at ${path}.shape (see cause)`, {cause: errors});\n\t\t\t}\n\n\t\t\tvalidatorInstance.shape(shape, `${path}.shape`);\n\t\t}\n\n\t\treturn validatorInstance;\n\t}\n\n\tprotected _nullable: Option<null> = Option.None();\n\tprotected _min: Option<number> = Option.None();\n\tprotected _max: Option<number> = Option.None();\n\tprotected _every: Option<Validator> = Option.None();\n\tprotected _shape: Option<{ [key: string]: Validator }> = Option.None();\n\tprotected _exact: Option<null> = Option.None();\n\n\n\tpublic nullable<const F extends boolean = true>(flag?: F): ObjectValidator<T, S, TD, SD, F, E> {\n\t\tthis._nullable = (flag ?? true) ? Option.Some(null) : Option.None();\n\n\t\treturn this as unknown as ObjectValidator<T, S, TD, SD, F, E>;\n\t}\n\n\tpublic min(value: number, path: string = 'min'): this {\n\t\tif (this._max.isSome() && this._max.value < value)\n\t\t\tthrow new DefinitionError(`Expected Minimum Rule to be smaller than or equal to Maximum Rule at Path ${path}`);\n\n\t\tif (this._shape.isSome() && value < Object.keys(this._shape.value).length)\n\t\t\tthrow new DefinitionError(`Expected Minimum Rule to be larger than or equal to Shape Key Count at Path ${path}`);\n\n\t\tif (this._exact.isSome() && this._shape.isSome() && value > Object.keys(this._shape.value).length)\n\t\t\tthrow new DefinitionError(`Expected Minimum Rule to be smaller than or equal to Shape Key Count due to Exact Rule at Path ${path}`);\n\n\t\tthis._min = Option.Some(value);\n\n\t\treturn this;\n\t}\n\n\tpublic max(value: number, path: string = 'max'): this {\n\t\tif (this._min.isSome() && this._min.value > value)\n\t\t\tthrow new DefinitionError(`Expected Maximum Rule to be larger than or equal to Minimum Rule at Path ${path}`);\n\n\t\tif (this._shape.isSome() && value < Object.keys(this._shape.value).length)\n\t\t\tthrow new DefinitionError(`Expected Maximum Rule to be larger than or equal to Shape Key Count at Path ${path}`);\n\n\t\tthis._max = Option.Some(value);\n\n\t\treturn this;\n\t}\n\n\tpublic every<V extends Validator>(validator: V): ObjectValidator<\n\t\tInferValidatorReturnType<V>,\n\t\tS,\n\t\tInferDefinitionType<V>,\n\t\tSD,\n\t\tN,\n\t\tE\n\t> {\n\t\tthis._every = Option.Some(validator);\n\n\t\treturn this as unknown as ObjectValidator<InferValidatorReturnType<V>, S, InferDefinitionType<V>, SD, N, E>;\n\t}\n\n\tpublic shape<S extends { [key: string]: Validator }>(value: S, path: string = 'shape'): ObjectValidator<\n\t\tT,\n\t\tInferObjectReturnType<S>,\n\t\tTD,\n\t\tInferObjectDefinitionType<S>,\n\t\tN,\n\t\tE\n\t> {\n\t\tconst shapeKeyCount = Object.keys(value).length;\n\n\t\tif (this._min.isSome() && this._min.value < shapeKeyCount)\n\t\t\tthrow new DefinitionError(`Expected Shape Key Count to be smaller than or equal to Minimum Rule at Path ${path}`);\n\n\t\tif (this._max.isSome() && this._max.value < shapeKeyCount)\n\t\t\tthrow new DefinitionError(`Expected Shape Key Count to be smaller than or equal to Maximum Rule at Path ${path}`);\n\n\t\tif (this._exact.isSome() && this._min.isSome() && this._min.value > shapeKeyCount)\n\t\t\tthrow new DefinitionError(`Expected Shape Key Count to be larger than or equal to Minimum Rule due to Exact Rule at Path ${path}`);\n\n\t\tif (this._exact.isSome() && this._max.isSome() && this._max.value < shapeKeyCount)\n\t\t\tthrow new DefinitionError(`Expected Shape Key Count to be smaller than or equal to Maximum Rule due to Exact Rule at Path ${path}`);\n\n\t\tthis._shape = Option.Some(value);\n\n\t\treturn this as unknown as ObjectValidator<T, InferObjectReturnType<S>, TD, InferObjectDefinitionType<S>, N, E>;\n\t}\n\n\tpublic exact<const F extends boolean = true>(flag?: F, path: string = 'exact'): ObjectValidator<T, S, TD, SD, N, F> {\n\t\tif ((flag ?? true) && this._shape.isSome()) {\n\t\t\tconst shapeKeyCount = Object.keys(this._shape.value).length;\n\n\t\t\tif (this._min.isSome() && this._min.value > shapeKeyCount)\n\t\t\t\tthrow new DefinitionError(`Expected Exact Rule to be false due to Minimum Rule requiring more Properties than Shape defines at Path ${path}`);\n\n\t\t\tif (this._max.isSome() && this._max.value < shapeKeyCount)\n\t\t\t\tthrow new DefinitionError(`Expected Exact Rule to be false due to Maximum Rule allowing fewer Properties than Shape defines at Path ${path}`);\n\t\t}\n\n\t\tthis._exact = (flag ?? true) ? Option.Some(null) : Option.None();\n\n\t\treturn this as unknown as ObjectValidator<T, S, TD, SD, N, F>;\n\t}\n\n\tpublic assert(data: unknown, path: string = \"data\"): asserts data is ApplyNullability<ObjectResult<T, S, E>, N> {\n\t\tif(JSON.isShallowObject(data)) {\n\t\t\tconst keys = Object.keys(data);\n\n\t\t\tif (this._min.isSome() && keys.length < this._min.value)\n\t\t\t\tthrow new AssertError(`Expected ${path} to have at least ${this._min.value} Properties`);\n\n\t\t\tif (this._max.isSome() && keys.length > this._max.value)\n\t\t\t\tthrow new AssertError(`Expected ${path} to have at most ${this._max.value} Properties`);\n\n\t\t\tconst errors: AssertError[] = [];\n\n\t\t\tif (this._shape.isSome()) {\n\t\t\t\tfor (const key of Object.keys(this._shape.value)) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst validator: Validator = this._shape.value[key]!;\n\n\t\t\t\t\t\tvalidator.assert(data[key], `${path}.${key}`);\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\tif (!(e instanceof AssertError))\n\t\t\t\t\t\t\tthrow new AssertError(`Fatal Error: Undefined Error thrown by an Assert Method at ${path}.${key}`);\n\n\t\t\t\t\t\terrors.push(e);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (this._exact.isSome()) {\n\t\t\t\t\tfor (const key of keys) {\n\t\t\t\t\t\tif (!(key in this._shape.value)) {\n\t\t\t\t\t\t\terrors.push(new AssertError(`Unexpected property ${path}.${key}`));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (this._every.isSome()) {\n\t\t\t\tconst validator: Validator = this._every.value;\n\n\t\t\t\tfor (const key of keys) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tvalidator.assert(data[key], `${path}.${key}`);\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\tif (!(e instanceof AssertError))\n\t\t\t\t\t\t\tthrow new AssertError(`Fatal Error: Undefined Error thrown by an Assert Method at ${path}.${key}`);\n\n\t\t\t\t\t\terrors.push(e);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (errors.length > 0)\n\t\t\t\tthrow new AssertError(`Multiple Errors while asserting ${path} (see cause)`, {cause: errors});\n\t\t}\n\t\telse if(JSON.isNull(data)) {\n\t\t\tif(!this._nullable.isSome())\n\t\t\t\tthrow new AssertError(`Expected ${path} to be an Object${this._nullable.isSome() ? ' or Null' : ''}`);\n\t\t}\n\t\telse\n\t\t\tthrow new AssertError(`Expected ${path} to be an Object${this._nullable.isSome() ? ' or Null' : ''}`);\n\t}\n\n\tpublic isSubset(other: Validator): boolean {\n\t\tif(other instanceof JSONValidator)\n\t\t\treturn true;\n\n\t\t// Must be the same validator type\n\t\tif (!(other instanceof ObjectValidator))\n\t\t\treturn false;\n\n\t\t// ---- 1) Nullability ----\n\t\t// If this allows null, the other must allow null as well\n\t\tif (this._nullable.isSome() && !other._nullable.isSome())\n\t\t\treturn false;\n\n\t\t// ---- 2) Min / Max (property count) ----\n\t\t// For subset: this must be at least as strict as other.\n\t\tconst thisMin = this._min.isSome() ? this._min.value : 0;\n\t\tconst otherMin = other._min.isSome() ? other._min.value : 0;\n\t\tif (thisMin < otherMin)\n\t\t\treturn false;\n\n\t\tconst thisMax = this._max.isSome() ? this._max.value : Number.POSITIVE_INFINITY;\n\t\tconst otherMax = other._max.isSome() ? other._max.value : Number.POSITIVE_INFINITY;\n\t\tif (thisMax > otherMax)\n\t\t\treturn false;\n\n\t\t// ---- 3) Shape requirements ----\n\t\t// If other requires certain keys (shape), this must also require them, and be compatible per key.\n\t\tif (other._shape.isSome()) {\n\t\t\tif (!this._shape.isSome())\n\t\t\t\treturn false;\n\n\t\t\tconst thisShape = this._shape.value;\n\t\t\tconst otherShape = other._shape.value;\n\n\t\t\tfor (const key of Object.keys(otherShape)) {\n\t\t\t\tif (!(key in thisShape))\n\t\t\t\t\treturn false;\n\n\t\t\t\tconst a = thisShape[key]!;\n\t\t\t\tconst b = otherShape[key]!;\n\t\t\t\tif (!a.isSubset(b))\n\t\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\t// ---- 4) Exactness ----\n\t\t// If other is exact, then this must be exact AND must have the exact same key set as other.shape.\n\t\tif (other._exact.isSome()) {\n\t\t\tif (!this._exact.isSome())\n\t\t\t\treturn false;\n\n\t\t\tif (!other._shape.isSome() || !this._shape.isSome())\n\t\t\t\treturn false;\n\n\t\t\tconst aKeys = Object.keys(this._shape.value).sort();\n\t\t\tconst bKeys = Object.keys(other._shape.value).sort();\n\n\t\t\tif (aKeys.length !== bKeys.length)\n\t\t\t\treturn false;\n\n\t\t\tfor (let i = 0; i < aKeys.length; i++) {\n\t\t\t\tif (aKeys[i] !== bKeys[i])\n\t\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\t// ---- 5) \"every\" constraint ----\n\t\t// If other has an \"every\" constraint, all values in any object accepted by this must satisfy it.\n\t\tif (other._every.isSome()) {\n\t\t\tconst bEvery = other._every.value;\n\n\t\t\t// All *possible* properties accepted by this must be constrained to bEvery.\n\t\t\t// If this can accept arbitrary keys (not exact), then we need this.every \u2286 bEvery.\n\t\t\tif (!this._exact.isSome()) {\n\t\t\t\tif (!this._every.isSome())\n\t\t\t\t\treturn false;\n\n\t\t\t\tif (!this._every.value.isSubset(bEvery))\n\t\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Additionally, any explicitly shaped properties must also imply bEvery.\n\t\t\t// (Even if this.every exists, shape validators might allow values outside bEvery.)\n\t\t\tif (this._shape.isSome()) {\n\t\t\t\tfor (const [_, v] of Object.entries(this._shape.value)) {\n\t\t\t\t\tif (!v.isSubset(bEvery))\n\t\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// If this is exact and has a shape, then there are no unknown keys;\n\t\t\t// the per-shape check above is sufficient (and this.every is optional).\n\t\t\tif (this._exact.isSome() && !this._shape.isSome()) {\n\t\t\t\t// Exact without shape is effectively meaningless for bounding keys,\n\t\t\t\t// so conservatively require this.every in that case.\n\t\t\t\tif (!this._every.isSome())\n\t\t\t\t\treturn false;\n\n\t\t\t\tif (!this._every.value.isSubset(bEvery))\n\t\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\t// If other has no \"every\", this can be stricter or looser on value-types freely (as long as above holds).\n\n\t\treturn true;\n\t}\n\n\tpublic isEquals(other: Validator): boolean {\n\t\tif (!(other instanceof ObjectValidator))\n\t\t\treturn false;\n\n\t\tif (this._nullable.isSome() !== other._nullable.isSome())\n\t\t\treturn false;\n\n\t\tif (this._min.isSome() !== other._min.isSome())\n\t\t\treturn false;\n\n\t\tif (this._min.isSome() && other._min.isSome() && this._min.value !== other._min.value)\n\t\t\treturn false;\n\n\t\tif (this._max.isSome() !== other._max.isSome())\n\t\t\treturn false;\n\n\t\tif (this._max.isSome() && other._max.isSome() && this._max.value !== other._max.value)\n\t\t\treturn false;\n\n\t\tif (this._every.isSome() !== other._every.isSome())\n\t\t\treturn false;\n\n\t\tif (this._every.isSome() && other._every.isSome())\n\t\t\treturn isEquals(this._every.value, other._every.value);\n\n\t\tif (this._shape.isSome() !== other._shape.isSome())\n\t\t\treturn false;\n\n\t\tif (this._shape.isSome() && other._shape.isSome()) {\n\t\t\tif(Object.keys(this._shape.value).length !== Object.keys(other._shape.value).length)\n\t\t\t\treturn false;\n\n\t\t\tfor(const [k, v] of Object.entries(this._shape.value)) {\n\t\t\t\tif(!(other._shape.value[k] instanceof Validator))\n\t\t\t\t\treturn false;\n\n\t\t\t\tif(!isEquals(v, other._shape.value[k]))\n\t\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\tif (this._exact.isSome() !== other._exact.isSome())\n\t\t\treturn false;\n\n\t\treturn true;\n\t}\n\n\tpublic toJSON(): ObjectValidatorDefinition<TD, SD> {\n\t\tconst schema: ObjectValidatorDefinition = {type: \"object\"};\n\n\t\tif (this._nullable.isSome())\n\t\t\tschema.nullable = true;\n\n\t\tif (this._exact.isSome())\n\t\t\tschema.exact = true;\n\n\t\tif (this._min.isSome())\n\t\t\tschema.min = this._min.value;\n\n\t\tif (this._max.isSome())\n\t\t\tschema.max = this._max.value;\n\n\t\tif (this._every.isSome())\n\t\t\tschema.every = this._every.value.toJSON();\n\n\t\tif (this._shape.isSome()) {\n\t\t\tschema.shape = Object.fromEntries(\n\t\t\t\tObject.entries(this._shape.value).map(([k, s]) => [k, s.toJSON()])\n\t\t\t) as any;\n\t\t}\n\n\t\treturn schema as ObjectValidatorDefinition<TD, SD>;\n\t}\n}", "import type {Validator} from '../Validator';\nimport {JSONValidator} from '../validators/JSON';\nimport {BooleanValidator} from '../validators/Boolean';\nimport {NumberValidator} from '../validators/Number';\nimport {StringValidator} from '../validators/String';\nimport {ArrayValidator} from '../validators/Array';\nimport {ObjectValidator} from '../validators/Object';\n\nexport function isEquals(\n\ta: Validator,\n\tb: Validator,\n): boolean {\n\tif(a instanceof JSONValidator)\n\t\treturn a.isEquals(b);\n\n\tif(a instanceof BooleanValidator)\n\t\treturn a.isEquals(b);\n\n\tif(a instanceof NumberValidator)\n\t\treturn a.isEquals(b);\n\n\tif(a instanceof StringValidator)\n\t\treturn a.isEquals(b);\n\n\tif(a instanceof ArrayValidator)\n\t\treturn a.isEquals(b);\n\n\tif(a instanceof ObjectValidator)\n\t\treturn a.isEquals(b);\n\n\treturn false;\n}"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,wDAAAA,UAAA;AAAA;AACA,WAAO,eAAeA,UAAS,cAAc,EAAE,OAAO,KAAK,CAAC;AAC5D,IAAAA,SAAQ,OAAO;AACf,QAAIC;AACJ,KAAC,SAAUA,OAAM;AACb,eAAS,OAAO,OAAO;AACnB,eAAO,UAAU;AAAA,MACrB;AACA,MAAAA,MAAK,SAAS;AACd,eAAS,UAAU,OAAO;AACtB,eAAO,OAAO,UAAU;AAAA,MAC5B;AACA,MAAAA,MAAK,YAAY;AACjB,eAAS,SAAS,OAAO;AAErB,eAAO,OAAO,SAAS,KAAK;AAAA,MAChC;AACA,MAAAA,MAAK,WAAW;AAChB,eAAS,UAAU,OAAO;AAEtB,eAAO,OAAO,cAAc,KAAK;AAAA,MACrC;AACA,MAAAA,MAAK,YAAY;AACjB,eAAS,SAAS,OAAO;AACrB,eAAO,OAAO,UAAU;AAAA,MAC5B;AACA,MAAAA,MAAK,WAAW;AAChB,eAAS,eAAe,OAAO;AAC3B,eAAO,MAAM,QAAQ,KAAK;AAAA,MAC9B;AACA,MAAAA,MAAK,iBAAiB;AACtB,eAAS,QAAQ,OAAO;AACpB,eAAO,eAAe,KAAK,KAAK,MAAM,MAAM,CAAC,MAAM,OAAO,CAAC,CAAC;AAAA,MAChE;AACA,MAAAA,MAAK,UAAU;AACf,eAAS,gBAAgB,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yB;AAC5E,WAAO,SAAS,YAAY,IAAI;AAAA,EACjC;AAAA,EAEA,OAAO,SAAS,GAAc,GAAuB;AACpD,WAAO,SAAS,GAAG,CAAC;AAAA,EACrB;AACD;AAEO,IAAM,aAAa;AAAA,EACzB,MAAM;AAAA,EACN,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,QAAQ;AACT;",
|
|
6
6
|
"names": ["exports", "JSON", "exports", "Option", "import_json", "import_json", "import_json", "import_option", "import_json", "import_option", "import_json", "import_option", "import_json", "import_option"]
|
|
7
7
|
}
|
package/package.json
CHANGED
package/types/Validator.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Definition } from './lib/util';
|
|
|
2
2
|
export declare abstract class Validator<T = unknown> {
|
|
3
3
|
abstract assert(data: unknown, path: string): asserts data is T;
|
|
4
4
|
abstract isSubset(other: Validator): boolean;
|
|
5
|
+
abstract isEquals(other: Validator): boolean;
|
|
5
6
|
validate(data: unknown, path?: string): T;
|
|
6
7
|
is(data: unknown, path?: string): data is T;
|
|
7
8
|
abstract toJSON(): Definition;
|
package/types/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export declare class Schema {
|
|
|
14
14
|
static get Array(): ArrayValidator;
|
|
15
15
|
static get Object(): ObjectValidator;
|
|
16
16
|
static fromJSON(definition: unknown, path?: string): Validator;
|
|
17
|
+
static isEquals(a: Validator, b: Validator): boolean;
|
|
17
18
|
}
|
|
18
19
|
export declare const Validators: {
|
|
19
20
|
readonly JSON: typeof JSONValidator;
|
|
@@ -32,6 +32,7 @@ export declare class ArrayValidator<E = unknown, T = unknown, ED extends Definit
|
|
|
32
32
|
tuple<const V extends readonly Validator[]>(validators: V, path?: string): ArrayValidator<E, InferListReturnType<V>, ED, InferListDefinitionType<V>, N>;
|
|
33
33
|
assert(data: unknown, path?: string): asserts data is ApplyNullability<ArrayResult<E, T>, N>;
|
|
34
34
|
isSubset(other: Validator): boolean;
|
|
35
|
+
isEquals(other: Validator): boolean;
|
|
35
36
|
toJSON(): ArrayValidatorDefinition<ED, TD>;
|
|
36
37
|
}
|
|
37
38
|
export {};
|
|
@@ -17,5 +17,6 @@ export declare class BooleanValidator<T extends JSON.Boolean = JSON.Boolean, N e
|
|
|
17
17
|
equals<const V extends boolean>(value: V): BooleanValidator<V, N>;
|
|
18
18
|
assert(data: unknown, path?: string): asserts data is ApplyNullability<T, N>;
|
|
19
19
|
isSubset(other: Validator): boolean;
|
|
20
|
+
isEquals(other: Validator): boolean;
|
|
20
21
|
toJSON(): BooleanValidatorDefinition;
|
|
21
22
|
}
|
|
@@ -10,5 +10,6 @@ export declare class JSONValidator<T extends JSON.JSON = JSON.JSON> extends Vali
|
|
|
10
10
|
}, _path?: string): Validator;
|
|
11
11
|
assert(data: unknown, path?: string): asserts data is JSON.JSON;
|
|
12
12
|
isSubset(other: Validator): boolean;
|
|
13
|
+
isEquals(other: Validator): boolean;
|
|
13
14
|
toJSON(): JSONValidatorDefinition;
|
|
14
15
|
}
|
|
@@ -26,5 +26,6 @@ export declare class NumberValidator<T extends JSON.Number = JSON.Number, N exte
|
|
|
26
26
|
max(value: number, path?: string): this;
|
|
27
27
|
assert(data: unknown, path?: string): asserts data is ApplyNullability<T, N>;
|
|
28
28
|
isSubset(other: Validator): boolean;
|
|
29
|
+
isEquals(other: Validator): boolean;
|
|
29
30
|
toJSON(): NumberValidatorDefinition;
|
|
30
31
|
}
|
|
@@ -51,6 +51,7 @@ export declare class ObjectValidator<T = unknown, S = unknown, TD extends Defini
|
|
|
51
51
|
exact<const F extends boolean = true>(flag?: F, path?: string): ObjectValidator<T, S, TD, SD, N, F>;
|
|
52
52
|
assert(data: unknown, path?: string): asserts data is ApplyNullability<ObjectResult<T, S, E>, N>;
|
|
53
53
|
isSubset(other: Validator): boolean;
|
|
54
|
+
isEquals(other: Validator): boolean;
|
|
54
55
|
toJSON(): ObjectValidatorDefinition<TD, SD>;
|
|
55
56
|
}
|
|
56
57
|
export {};
|
|
@@ -23,5 +23,6 @@ export declare class StringValidator<T extends JSON.String = JSON.String, N exte
|
|
|
23
23
|
max(value: number, path?: string): this;
|
|
24
24
|
assert(data: unknown, path?: string): asserts data is ApplyNullability<T, N>;
|
|
25
25
|
isSubset(other: Validator): boolean;
|
|
26
|
+
isEquals(other: Validator): boolean;
|
|
26
27
|
toJSON(): StringValidatorDefinition;
|
|
27
28
|
}
|