Socket
Socket
Sign inDemoInstall

@sapphire/shapeshift

Package Overview
Dependencies
Maintainers
3
Versions
444
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sapphire/shapeshift - npm Package Compare versions

Comparing version 1.1.0-next.8727427.0 to 1.1.0-next.18d20d1.0

193

dist/index.d.ts

@@ -1,16 +0,78 @@

declare class ConstraintError<T = unknown> extends Error {
readonly constraint: string;
/// <reference types="node" />
import { InspectOptionsStylized } from 'node:util';
declare type ArrayConstraintName = `s.array(T).length${'Lt' | 'Le' | 'Gt' | 'Ge' | 'Eq' | 'Ne'}`;
declare function arrayLengthLt<T>(value: number): IConstraint<T[]>;
declare function arrayLengthLe<T>(value: number): IConstraint<T[]>;
declare function arrayLengthGt<T>(value: number): IConstraint<T[]>;
declare function arrayLengthGe<T>(value: number): IConstraint<T[]>;
declare function arrayLengthEq<T>(value: number): IConstraint<T[]>;
declare function arrayLengthNe<T>(value: number): IConstraint<T[]>;
declare type BigIntConstraintName = `s.bigint.${'lt' | 'le' | 'gt' | 'ge' | 'eq' | 'ne' | 'divisibleBy'}`;
declare function bigintLt(value: bigint): IConstraint<bigint>;
declare function bigintLe(value: bigint): IConstraint<bigint>;
declare function bigintGt(value: bigint): IConstraint<bigint>;
declare function bigintGe(value: bigint): IConstraint<bigint>;
declare function bigintEq(value: bigint): IConstraint<bigint>;
declare function bigintNe(value: bigint): IConstraint<bigint>;
declare function bigintDivisibleBy(divider: bigint): IConstraint<bigint>;
declare type BooleanConstraintName = `s.boolean.${boolean}`;
declare const booleanTrue: IConstraint<boolean, true>;
declare const booleanFalse: IConstraint<boolean, false>;
declare type DateConstraintName = `s.date.${'lt' | 'le' | 'gt' | 'ge' | 'eq' | 'eq(NaN)' | 'ne' | 'ne(NaN)'}`;
declare function dateLt(value: Date): IConstraint<Date>;
declare function dateLe(value: Date): IConstraint<Date>;
declare function dateGt(value: Date): IConstraint<Date>;
declare function dateGe(value: Date): IConstraint<Date>;
declare function dateEq(value: Date): IConstraint<Date>;
declare function dateNe(value: Date): IConstraint<Date>;
declare const dateInvalid: IConstraint<Date>;
declare const dateValid: IConstraint<Date>;
declare type NumberConstraintName = `s.number.${'lt' | 'le' | 'gt' | 'ge' | 'eq' | 'eq(NaN)' | 'ne' | 'ne(NaN)' | 'int' | 'safeInt' | 'finite' | 'divisibleBy'}`;
declare function numberLt(value: number): IConstraint<number>;
declare function numberLe(value: number): IConstraint<number>;
declare function numberGt(value: number): IConstraint<number>;
declare function numberGe(value: number): IConstraint<number>;
declare function numberEq(value: number): IConstraint<number>;
declare function numberNe(value: number): IConstraint<number>;
declare const numberInt: IConstraint<number>;
declare const numberSafeInt: IConstraint<number>;
declare const numberFinite: IConstraint<number>;
declare const numberNaN: IConstraint<number>;
declare const numberNeNaN: IConstraint<number>;
declare function numberDivisibleBy(divider: number): IConstraint<number>;
declare type StringConstraintName = `s.string.length${'Lt' | 'Le' | 'Gt' | 'Ge' | 'Eq' | 'Ne'}`;
declare function stringLengthLt(length: number): IConstraint<string>;
declare function stringLengthLe(length: number): IConstraint<string>;
declare function stringLengthGt(length: number): IConstraint<string>;
declare function stringLengthGe(length: number): IConstraint<string>;
declare function stringLengthEq(length: number): IConstraint<string>;
declare function stringLengthNe(length: number): IConstraint<string>;
declare const customInspectSymbol: unique symbol;
declare const customInspectSymbolStackLess: unique symbol;
declare abstract class BaseError extends Error {
protected [customInspectSymbol](depth: number, options: InspectOptionsStylized): string;
protected abstract [customInspectSymbolStackLess](depth: number, options: InspectOptionsStylized): string;
}
declare type ConstraintErrorNames = ArrayConstraintName | BigIntConstraintName | BooleanConstraintName | DateConstraintName | NumberConstraintName | StringConstraintName;
declare class ConstraintError<T = unknown> extends BaseError {
readonly constraint: ConstraintErrorNames;
readonly given: T;
readonly expected: unknown;
constructor(validator: string, message: string, given: T, expected: unknown);
readonly expected: string;
constructor(constraint: ConstraintErrorNames, message: string, given: T, expected: string);
toJSON(): {
name: string;
constraint: string;
constraint: ConstraintErrorNames;
given: T;
expected: unknown;
expected: string;
};
protected [customInspectSymbolStackLess](depth: number, options: InspectOptionsStylized): string;
}
interface ConstraintErrorMessageBuilder<Given = unknown, Expected = unknown> {
(given: Given, expected: Expected): string;
}

@@ -39,3 +101,9 @@ declare class Result<T, E extends Error = Error> {

declare class ValidationError extends Error {
declare class CombinedError extends BaseError {
readonly errors: readonly BaseError[];
constructor(errors: readonly BaseError[]);
protected [customInspectSymbolStackLess](depth: number, options: InspectOptionsStylized): string;
}
declare class ValidationError extends BaseError {
readonly validator: string;

@@ -49,2 +117,3 @@ readonly given: unknown;

};
protected [customInspectSymbolStackLess](depth: number, options: InspectOptionsStylized): string;
}

@@ -61,6 +130,9 @@

or<O>(...predicates: readonly BaseValidator<O>[]): UnionValidator<T | O>;
run(value: unknown): Result<T, Error>;
transform(cb: (value: T) => T): this;
transform<O>(cb: (value: T) => O): BaseValidator<O>;
default(value: T | (() => T)): DefaultValidator<T>;
run(value: unknown): Result<T, BaseError>;
parse(value: unknown): T;
protected clone(): this;
protected abstract handle(value: unknown): Result<T, ValidationError | AggregateError>;
protected abstract handle(value: unknown): Result<T, ValidationError | CombinedError>;
protected addConstraint(constraint: IConstraint<T>): this;

@@ -73,3 +145,3 @@ }

protected clone(): this;
protected handle(values: unknown): Result<T[], ValidationError | AggregateError>;
protected handle(values: unknown): Result<T[], ValidationError | CombinedError>;
}

@@ -86,2 +158,6 @@

get negative(): this;
divisibleBy(number: bigint): this;
get abs(): this;
intN(bits: number): this;
uintN(bits: number): this;
protected handle(value: unknown): Result<T, ValidationError>;

@@ -117,2 +193,3 @@ }

};
protected [customInspectSymbolStackLess](depth: number, options: InspectOptionsStylized): string;
}

@@ -161,2 +238,10 @@

get negative(): this;
divisibleBy(divider: number): this;
get abs(): this;
get sign(): this;
get trunc(): this;
get floor(): this;
get fround(): this;
get round(): this;
get ceil(): this;
protected handle(value: unknown): Result<T, ValidationError>;

@@ -185,3 +270,3 @@ }

}>;
protected handle(value: unknown): Result<T, ValidationError | AggregateError>;
protected handle(value: unknown): Result<T, ValidationError | CombinedError>;
protected clone(): this;

@@ -204,3 +289,3 @@ private handleIgnoreStrategy;

protected clone(): this;
protected handle(value: unknown): Result<Record<string, T>, ValidationError | AggregateError>;
protected handle(value: unknown): Result<Record<string, T>, ValidationError | CombinedError>;
}

@@ -212,10 +297,10 @@

protected clone(): this;
protected handle(values: unknown): Result<Set<T>, ValidationError | AggregateError>;
protected handle(values: unknown): Result<Set<T>, ValidationError | CombinedError>;
}
declare class StringValidator<T extends string> extends BaseValidator<T> {
lengthLt(length: number): this;
lengthLe(length: number): this;
lengthLte(length: number): this;
lengthGt(length: number): this;
lengthGe(length: number): this;
lengthGte(length: number): this;
lengthEq(length: number): this;

@@ -234,5 +319,21 @@ lengthNe(length: number): this;

protected clone(): this;
protected handle(value: unknown): Result<T, ValidationError | AggregateError>;
protected handle(value: unknown): Result<T, ValidationError | CombinedError>;
}
declare class MapValidator<K, V> extends BaseValidator<Map<K, V>> {
private readonly keyValidator;
private readonly valueValidator;
constructor(keyValidator: BaseValidator<K>, valueValidator: BaseValidator<V>, constraints?: readonly IConstraint<Map<K, V>>[]);
protected clone(): this;
protected handle(value: unknown): Result<Map<K, V>, ValidationError | CombinedError>;
}
declare class DefaultValidator<T> extends BaseValidator<T | undefined> {
private readonly validator;
private readonly defaultValue;
constructor(validator: BaseValidator<T>, value: T | (() => T), constraints?: readonly IConstraint<T>[]);
protected handle(value: unknown): Result<T, ValidationError | CombinedError>;
protected clone(): this;
}
declare class Shapes {

@@ -258,5 +359,6 @@ get string(): StringValidator<string>;

record<T>(validator: BaseValidator<T>): RecordValidator<T>;
map<T, U>(keyValidator: BaseValidator<T>, valueValidator: BaseValidator<U>): MapValidator<T, U>;
}
declare class MissingPropertyError extends Error {
declare class MissingPropertyError extends BaseError {
readonly property: PropertyKey;

@@ -268,5 +370,6 @@ constructor(property: PropertyKey);

};
protected [customInspectSymbolStackLess](depth: number, options: InspectOptionsStylized): string;
}
declare class UnknownPropertyError extends Error {
declare class UnknownPropertyError extends BaseError {
readonly property: PropertyKey;

@@ -280,51 +383,7 @@ readonly value: unknown;

};
protected [customInspectSymbolStackLess](depth: number, options: InspectOptionsStylized): string;
}
declare const arrayLengthLt: (length: number) => IConstraint<unknown[], unknown[]>;
declare const arrayLengthLe: (length: number) => IConstraint<unknown[], unknown[]>;
declare const arrayLengthGt: (length: number) => IConstraint<unknown[], unknown[]>;
declare const arrayLengthGe: (length: number) => IConstraint<unknown[], unknown[]>;
declare const arrayLengthEq: (length: number) => IConstraint<unknown[], unknown[]>;
declare const arrayLengthNe: (length: number) => IConstraint<unknown[], unknown[]>;
declare const bigintLt: (number: bigint) => IConstraint<bigint, bigint>;
declare const bigintLe: (number: bigint) => IConstraint<bigint, bigint>;
declare const bigintGt: (number: bigint) => IConstraint<bigint, bigint>;
declare const bigintGe: (number: bigint) => IConstraint<bigint, bigint>;
declare const bigintEq: (number: bigint) => IConstraint<bigint, bigint>;
declare const bigintNe: (number: bigint) => IConstraint<bigint, bigint>;
declare const booleanTrue: IConstraint<boolean, true>;
declare const booleanFalse: IConstraint<boolean, false>;
declare const dateLt: (date: Date, number?: number | undefined) => IConstraint<Date, Date>;
declare const dateLe: (date: Date, number?: number | undefined) => IConstraint<Date, Date>;
declare const dateGt: (date: Date, number?: number | undefined) => IConstraint<Date, Date>;
declare const dateGe: (date: Date, number?: number | undefined) => IConstraint<Date, Date>;
declare const dateEq: (date: Date, number?: number | undefined) => IConstraint<Date, Date>;
declare const dateNe: (date: Date, number?: number | undefined) => IConstraint<Date, Date>;
declare const dateInvalid: IConstraint<Date>;
declare const dateValid: IConstraint<Date>;
declare const numberLt: (number: number) => IConstraint<number, number>;
declare const numberLe: (number: number) => IConstraint<number, number>;
declare const numberGt: (number: number) => IConstraint<number, number>;
declare const numberGe: (number: number) => IConstraint<number, number>;
declare const numberEq: (number: number) => IConstraint<number, number>;
declare const numberNe: (number: number) => IConstraint<number, number>;
declare const numberInt: IConstraint<number>;
declare const numberSafeInt: IConstraint<number>;
declare const numberFinite: IConstraint<number>;
declare const numberNaN: IConstraint<number>;
declare const numberNeNaN: IConstraint<number>;
declare const stringLengthLt: (length: number) => IConstraint<string, string>;
declare const stringLengthLe: (length: number) => IConstraint<string, string>;
declare const stringLengthGt: (length: number) => IConstraint<string, string>;
declare const stringLengthGe: (length: number) => IConstraint<string, string>;
declare const stringLengthEq: (length: number) => IConstraint<string, string>;
declare const stringLengthNe: (length: number) => IConstraint<string, string>;
declare const s: Shapes;
export { ArrayValidator, BaseValidator, BigIntValidator, BooleanValidator, ConstraintError, ConstraintErrorMessageBuilder, Constructor, DateValidator, ExpectedValidationError, IConstraint, InstanceValidator, LiteralValidator, MappedObjectValidator, MissingPropertyError, NeverValidator, NonNullObject, NullishValidator, NumberValidator, ObjectValidator, ObjectValidatorStrategy, PassthroughValidator, RecordValidator, Result, SetValidator, Shapes, StringValidator, Type, UnionValidator, UnknownPropertyError, ValidationError, arrayLengthEq, arrayLengthGe, arrayLengthGt, arrayLengthLe, arrayLengthLt, arrayLengthNe, bigintEq, bigintGe, bigintGt, bigintLe, bigintLt, bigintNe, booleanFalse, booleanTrue, dateEq, dateGe, dateGt, dateInvalid, dateLe, dateLt, dateNe, dateValid, numberEq, numberFinite, numberGe, numberGt, numberInt, numberLe, numberLt, numberNaN, numberNe, numberNeNaN, numberSafeInt, s, stringLengthEq, stringLengthGe, stringLengthGt, stringLengthLe, stringLengthLt, stringLengthNe };
export { ArrayConstraintName, ArrayValidator, BaseError, BaseValidator, BigIntConstraintName, BigIntValidator, BooleanConstraintName, BooleanValidator, CombinedError, ConstraintError, ConstraintErrorNames, Constructor, DateConstraintName, DateValidator, DefaultValidator, ExpectedValidationError, IConstraint, InstanceValidator, LiteralValidator, MapValidator, MappedObjectValidator, MissingPropertyError, NeverValidator, NonNullObject, NullishValidator, NumberConstraintName, NumberValidator, ObjectValidator, ObjectValidatorStrategy, PassthroughValidator, RecordValidator, Result, SetValidator, Shapes, StringConstraintName, StringValidator, Type, UnionValidator, UnknownPropertyError, ValidationError, arrayLengthEq, arrayLengthGe, arrayLengthGt, arrayLengthLe, arrayLengthLt, arrayLengthNe, bigintDivisibleBy, bigintEq, bigintGe, bigintGt, bigintLe, bigintLt, bigintNe, booleanFalse, booleanTrue, dateEq, dateGe, dateGt, dateInvalid, dateLe, dateLt, dateNe, dateValid, numberDivisibleBy, numberEq, numberFinite, numberGe, numberGt, numberInt, numberLe, numberLt, numberNaN, numberNe, numberNeNaN, numberSafeInt, s, stringLengthEq, stringLengthGe, stringLengthGt, stringLengthLe, stringLengthLt, stringLengthNe };

@@ -1,2 +0,1 @@

"use strict";
var SapphireShapeshift = (() => {

@@ -9,2 +8,9 @@ var __defProp = Object.defineProperty;

var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
}) : x)(function(x) {
if (typeof require !== "undefined")
return require.apply(this, arguments);
throw new Error('Dynamic require of "' + x + '" is not supported');
});
var __export = (target, all) => {

@@ -31,2 +37,3 @@ for (var name in all)

__export(src_exports, {
CombinedError: () => CombinedError,
ConstraintError: () => ConstraintError,

@@ -41,2 +48,32 @@ ExpectedValidationError: () => ExpectedValidationError,

// src/lib/Result.ts
var Result = class {
constructor(success, value, error) {
this.success = success;
if (success) {
this.value = value;
} else {
this.error = error;
}
}
isOk() {
return this.success;
}
isErr() {
return !this.success;
}
unwrap() {
if (this.isOk())
return this.value;
throw this.error;
}
static ok(value) {
return new Result(true, value);
}
static err(error) {
return new Result(false, void 0, error);
}
};
__name(Result, "Result");
// src/validators/BaseValidator.ts

@@ -66,2 +103,8 @@ var BaseValidator = class {

}
transform(cb) {
return this.addConstraint({ run: (input) => Result.ok(cb(input)) });
}
default(value) {
return new DefaultValidator(this.clone(), value);
}
run(value) {

@@ -92,4 +135,44 @@ let result = this.handle(value);

// src/lib/errors/BaseError.ts
var customInspectSymbol = Symbol.for("nodejs.util.inspect.custom");
var customInspectSymbolStackLess = Symbol.for("nodejs.util.inspect.custom.stack-less");
var BaseError = class extends Error {
[customInspectSymbol](depth, options) {
return `${this[customInspectSymbolStackLess](depth, options)}
${this.stack.slice(this.stack.indexOf("\n"))}`;
}
};
__name(BaseError, "BaseError");
// src/lib/errors/CombinedError.ts
var CombinedError = class extends BaseError {
constructor(errors) {
super("Received one or more errors");
this.errors = errors;
}
[customInspectSymbolStackLess](depth, options) {
if (depth < 0) {
return options.stylize("[CombinedError]", "special");
}
const newOptions = { ...options, depth: options.depth === null ? null : options.depth - 1, compact: true };
const padding = `
${options.stylize("|", "undefined")} `;
const header = `${options.stylize("CombinedError", "special")} (${options.stylize(this.errors.length.toString(), "number")})`;
const message = options.stylize(this.message, "regexp");
const errors = this.errors.map((error, i) => {
const index = options.stylize((i + 1).toString(), "number");
const body = error[customInspectSymbolStackLess](depth - 1, newOptions).replaceAll("\n", padding);
return ` ${index} ${body}`;
}).join("\n\n");
return `${header}
${message}
${errors}`;
}
};
__name(CombinedError, "CombinedError");
// src/lib/errors/ValidationError.ts
var ValidationError = class extends Error {
var import_node_util = __require("util");
var ValidationError = class extends BaseError {
constructor(validator, message, given) {

@@ -107,34 +190,21 @@ super(message);

}
};
__name(ValidationError, "ValidationError");
// src/lib/Result.ts
var Result = class {
constructor(success, value, error) {
this.success = success;
if (success) {
this.value = value;
} else {
this.error = error;
[customInspectSymbolStackLess](depth, options) {
const validator = options.stylize(this.validator, "string");
if (depth < 0) {
return options.stylize(`[ValidationError: ${validator}]`, "special");
}
const newOptions = { ...options, depth: options.depth === null ? null : options.depth - 1, compact: true };
const padding = `
${options.stylize("|", "undefined")} `;
const given = (0, import_node_util.inspect)(this.given, newOptions).replaceAll("\n", padding);
const header = `${options.stylize("ValidationError", "special")} > ${validator}`;
const message = options.stylize(this.message, "regexp");
const givenBlock = `
${options.stylize("Received:", "regexp")}${padding}${given}`;
return `${header}
${message}
${givenBlock}`;
}
isOk() {
return this.success;
}
isErr() {
return !this.success;
}
unwrap() {
if (this.isOk())
return this.value;
throw this.error;
}
static ok(value) {
return new Result(true, value);
}
static err(error) {
return new Result(false, void 0, error);
}
};
__name(Result, "Result");
__name(ValidationError, "ValidationError");

@@ -163,3 +233,3 @@ // src/validators/ArrayValidator.ts

}
return errors.length === 0 ? Result.ok(transformed) : Result.err(new AggregateError(errors, "Failed to validate at least one entry"));
return errors.length === 0 ? Result.ok(transformed) : Result.err(new CombinedError(errors));
}

@@ -170,6 +240,7 @@ };

// src/lib/errors/ConstraintError.ts
var ConstraintError = class extends Error {
constructor(validator, message, given, expected) {
var import_node_util2 = __require("util");
var ConstraintError = class extends BaseError {
constructor(constraint, message, given, expected) {
super(message);
this.constraint = validator;
this.constraint = constraint;
this.given = given;

@@ -186,2 +257,22 @@ this.expected = expected;

}
[customInspectSymbolStackLess](depth, options) {
const constraint = options.stylize(this.constraint, "string");
if (depth < 0) {
return options.stylize(`[ConstraintError: ${constraint}]`, "special");
}
const newOptions = { ...options, depth: options.depth === null ? null : options.depth - 1 };
const padding = `
${options.stylize("|", "undefined")} `;
const given = (0, import_node_util2.inspect)(this.given, newOptions).replaceAll("\n", padding);
const header = `${options.stylize("ConstraintError", "special")} > ${constraint}`;
const message = options.stylize(this.message, "regexp");
const expectedBlock = `
${options.stylize("Expected: ", "string")}${options.stylize(this.expected, "boolean")}`;
const givenBlock = `
${options.stylize("Received:", "regexp")}${padding}${given}`;
return `${header}
${message}
${expectedBlock}
${givenBlock}`;
}
};

@@ -204,3 +295,3 @@ __name(ConstraintError, "ConstraintError");

function ge(a, b) {
return a > b;
return a >= b;
}

@@ -218,6 +309,6 @@ __name(ge, "ge");

// src/constraints/BigIntConstraints.ts
function bigintComparator(comparator, name, messageBuilder, number) {
function bigintComparator(comparator, name, expected, number) {
return {
run(input) {
return comparator(input, number) ? Result.ok(input) : Result.err(new ConstraintError(name, messageBuilder(input, number), input, number));
return comparator(input, number) ? Result.ok(input) : Result.err(new ConstraintError(name, "Invalid bigint value", input, expected));
}

@@ -227,8 +318,41 @@ };

__name(bigintComparator, "bigintComparator");
var bigintLt = bigintComparator.bind(null, lt, "bigintLt", (given, expected) => `Expected bigint to be less than ${expected}, but received ${given}`);
var bigintLe = bigintComparator.bind(null, le, "bigintLe", (given, expected) => `Expected bigint to be less or equals than ${expected}, but received ${given}`);
var bigintGt = bigintComparator.bind(null, gt, "bigintGt", (given, expected) => `Expected bigint to be greater than ${expected}, but received ${given}`);
var bigintGe = bigintComparator.bind(null, ge, "bigintGe", (given, expected) => `Expected bigint to be greater or equals than ${expected}, but received ${given}`);
var bigintEq = bigintComparator.bind(null, eq, "bigintEq", (given, expected) => `Expected bigint to be exactly ${expected}, but received ${given}`);
var bigintNe = bigintComparator.bind(null, ne, "bigintNe", (_, expected) => `Expected bigint to not be ${expected}`);
function bigintLt(value) {
const expected = `expected < ${value}n`;
return bigintComparator(lt, "s.bigint.lt", expected, value);
}
__name(bigintLt, "bigintLt");
function bigintLe(value) {
const expected = `expected <= ${value}n`;
return bigintComparator(le, "s.bigint.le", expected, value);
}
__name(bigintLe, "bigintLe");
function bigintGt(value) {
const expected = `expected > ${value}n`;
return bigintComparator(gt, "s.bigint.gt", expected, value);
}
__name(bigintGt, "bigintGt");
function bigintGe(value) {
const expected = `expected >= ${value}n`;
return bigintComparator(ge, "s.bigint.ge", expected, value);
}
__name(bigintGe, "bigintGe");
function bigintEq(value) {
const expected = `expected === ${value}n`;
return bigintComparator(eq, "s.bigint.eq", expected, value);
}
__name(bigintEq, "bigintEq");
function bigintNe(value) {
const expected = `expected !== ${value}n`;
return bigintComparator(ne, "s.bigint.ne", expected, value);
}
__name(bigintNe, "bigintNe");
function bigintDivisibleBy(divider) {
const expected = `expected % ${divider}n === 0n`;
return {
run(input) {
return input % divider === 0n ? Result.ok(input) : Result.err(new ConstraintError("s.bigint.divisibleBy", "BigInt is not divisible", input, expected));
}
};
}
__name(bigintDivisibleBy, "bigintDivisibleBy");

@@ -261,2 +385,14 @@ // src/validators/BigIntValidator.ts

}
divisibleBy(number) {
return this.addConstraint(bigintDivisibleBy(number));
}
get abs() {
return this.transform((value) => value < 0 ? -value : value);
}
intN(bits) {
return this.transform((value) => BigInt.asIntN(bits, value));
}
uintN(bits) {
return this.transform((value) => BigInt.asUintN(bits, value));
}
handle(value) {

@@ -271,3 +407,3 @@ return typeof value === "bigint" ? Result.ok(value) : Result.err(new ValidationError("BigIntValidator", "Expected a bigint primitive", value));

run(input) {
return input ? Result.ok(input) : Result.err(new ConstraintError("booleanTrue", "Expected boolean to be true, but received false", input, true));
return input ? Result.ok(input) : Result.err(new ConstraintError("s.boolean.true", "Invalid boolean value", input, "true"));
}

@@ -277,3 +413,3 @@ };

run(input) {
return input ? Result.err(new ConstraintError("booleanFalse", "Expected boolean to be false, but received true", input, false)) : Result.ok(input);
return input ? Result.err(new ConstraintError("s.boolean.false", "Invalid boolean value", input, "false")) : Result.ok(input);
}

@@ -303,6 +439,6 @@ };

// src/constraints/DateConstraints.ts
function dateComparator(comparator, name, messageBuilder, date, number = date.getTime()) {
function dateComparator(comparator, name, expected, number) {
return {
run(input) {
return comparator(input.getTime(), number) ? Result.ok(input) : Result.err(new ConstraintError(name, messageBuilder(input, date), input, date));
return comparator(input.getTime(), number) ? Result.ok(input) : Result.err(new ConstraintError(name, "Invalid Date value", input, expected));
}

@@ -312,11 +448,35 @@ };

__name(dateComparator, "dateComparator");
var dateLt = dateComparator.bind(null, lt, "dateLt", (given, expected) => `Expected date to be earlier than ${expected}, but received ${given}`);
var dateLe = dateComparator.bind(null, le, "dateLe", (given, expected) => `Expected date to be earlier or equals than ${expected}, but received ${given}`);
var dateGt = dateComparator.bind(null, gt, "dateGt", (given, expected) => `Expected date to be later than ${expected}, but received ${given}`);
var dateGe = dateComparator.bind(null, ge, "dateGe", (given, expected) => `Expected date to be later or equals than ${expected}, but received ${given}`);
var dateEq = dateComparator.bind(null, eq, "dateEq", (given, expected) => `Expected date to be exactly ${expected}, but received ${given}`);
var dateNe = dateComparator.bind(null, ne, "dateNe", (_, expected) => `Expected date to not be ${expected}`);
function dateLt(value) {
const expected = `expected < ${value}`;
return dateComparator(lt, "s.date.lt", expected, value.getTime());
}
__name(dateLt, "dateLt");
function dateLe(value) {
const expected = `expected <= ${value}`;
return dateComparator(le, "s.date.le", expected, value.getTime());
}
__name(dateLe, "dateLe");
function dateGt(value) {
const expected = `expected > ${value}`;
return dateComparator(gt, "s.date.gt", expected, value.getTime());
}
__name(dateGt, "dateGt");
function dateGe(value) {
const expected = `expected >= ${value}`;
return dateComparator(ge, "s.date.ge", expected, value.getTime());
}
__name(dateGe, "dateGe");
function dateEq(value) {
const expected = `expected === ${value}`;
return dateComparator(eq, "s.date.eq", expected, value.getTime());
}
__name(dateEq, "dateEq");
function dateNe(value) {
const expected = `expected !== ${value}`;
return dateComparator(ne, "s.date.ne", expected, value.getTime());
}
__name(dateNe, "dateNe");
var dateInvalid = {
run(input) {
return Number.isNaN(input.getTime()) ? Result.ok(input) : Result.err(new ConstraintError("dateInvalid", `Expected Date's time to be a NaN, but received ${input}`, input, "An invalid Date"));
return Number.isNaN(input.getTime()) ? Result.ok(input) : Result.err(new ConstraintError("s.date.eq(NaN)", "Invalid Date value", input, "expected === NaN"));
}

@@ -326,3 +486,3 @@ };

run(input) {
return Number.isNaN(input.getTime()) ? Result.err(new ConstraintError("dateValid", `Expected Date's time to not be a NaN, but received ${input}`, input, "A valid Date")) : Result.ok(input);
return Number.isNaN(input.getTime()) ? Result.err(new ConstraintError("s.date.ne(NaN)", "Invalid Date value", input, "expected !== NaN")) : Result.ok(input);
}

@@ -360,2 +520,3 @@ };

// src/lib/errors/ExpectedValidationError.ts
var import_node_util3 = __require("util");
var ExpectedValidationError = class extends ValidationError {

@@ -374,2 +535,23 @@ constructor(validator, message, given, expected) {

}
[customInspectSymbolStackLess](depth, options) {
const validator = options.stylize(this.validator, "string");
if (depth < 0) {
return options.stylize(`[ExpectedValidationError: ${validator}]`, "special");
}
const newOptions = { ...options, depth: options.depth === null ? null : options.depth - 1 };
const padding = `
${options.stylize("|", "undefined")} `;
const expected = (0, import_node_util3.inspect)(this.expected, newOptions).replaceAll("\n", padding);
const given = (0, import_node_util3.inspect)(this.given, newOptions).replaceAll("\n", padding);
const header = `${options.stylize("ExpectedValidationError", "special")} > ${validator}`;
const message = options.stylize(this.message, "regexp");
const expectedBlock = `
${options.stylize("Expected:", "string")}${padding}${expected}`;
const givenBlock = `
${options.stylize("Received:", "regexp")}${padding}${given}`;
return `${header}
${message}
${expectedBlock}
${givenBlock}`;
}
};

@@ -400,3 +582,3 @@ __name(ExpectedValidationError, "ExpectedValidationError");

handle(value) {
return Object.is(value, this.expected) ? Result.ok(value) : Result.err(new ExpectedValidationError("LiteralValidator", "Expected", value, this.expected));
return Object.is(value, this.expected) ? Result.ok(value) : Result.err(new ExpectedValidationError("LiteralValidator", "Expected values to be equals", value, this.expected));
}

@@ -426,6 +608,6 @@ clone() {

// src/constraints/NumberConstraints.ts
function numberComparator(comparator, name, messageBuilder, number) {
function numberComparator(comparator, name, expected, number) {
return {
run(input) {
return comparator(input, number) ? Result.ok(input) : Result.err(new ConstraintError(name, messageBuilder(input, number), input, number));
return comparator(input, number) ? Result.ok(input) : Result.err(new ConstraintError(name, "Invalid number value", input, expected));
}

@@ -435,11 +617,35 @@ };

__name(numberComparator, "numberComparator");
var numberLt = numberComparator.bind(null, lt, "numberLt", (given, expected) => `Expected number to be less than ${expected}, but received ${given}`);
var numberLe = numberComparator.bind(null, le, "numberLe", (given, expected) => `Expected number to be less or equals than ${expected}, but received ${given}`);
var numberGt = numberComparator.bind(null, gt, "numberGt", (given, expected) => `Expected number to be greater than ${expected}, but received ${given}`);
var numberGe = numberComparator.bind(null, ge, "numberGe", (given, expected) => `Expected number to be greater or equals than ${expected}, but received ${given}`);
var numberEq = numberComparator.bind(null, eq, "numberEq", (given, expected) => `Expected number to be exactly ${expected}, but received ${given}`);
var numberNe = numberComparator.bind(null, ne, "numberNe", (_, expected) => `Expected number to not be ${expected}`);
function numberLt(value) {
const expected = `expected < ${value}`;
return numberComparator(lt, "s.number.lt", expected, value);
}
__name(numberLt, "numberLt");
function numberLe(value) {
const expected = `expected <= ${value}`;
return numberComparator(le, "s.number.le", expected, value);
}
__name(numberLe, "numberLe");
function numberGt(value) {
const expected = `expected > ${value}`;
return numberComparator(gt, "s.number.gt", expected, value);
}
__name(numberGt, "numberGt");
function numberGe(value) {
const expected = `expected >= ${value}`;
return numberComparator(ge, "s.number.ge", expected, value);
}
__name(numberGe, "numberGe");
function numberEq(value) {
const expected = `expected === ${value}`;
return numberComparator(eq, "s.number.eq", expected, value);
}
__name(numberEq, "numberEq");
function numberNe(value) {
const expected = `expected !== ${value}`;
return numberComparator(ne, "s.number.ne", expected, value);
}
__name(numberNe, "numberNe");
var numberInt = {
run(input) {
return Number.isInteger(input) ? Result.ok(input) : Result.err(new ConstraintError("numberInt", `Expected number to be an integer, but received ${input}`, input, "An integer"));
return Number.isInteger(input) ? Result.ok(input) : Result.err(new ConstraintError("s.number.int", "Given value is not an integer", input, "Number.isInteger(expected) to be true"));
}

@@ -449,3 +655,3 @@ };

run(input) {
return Number.isSafeInteger(input) ? Result.ok(input) : Result.err(new ConstraintError("numberSafeInt", `Expected number to be a safe integer, but received ${input}`, input, "A safe integer"));
return Number.isSafeInteger(input) ? Result.ok(input) : Result.err(new ConstraintError("s.number.safeInt", "Given value is not a safe integer", input, "Number.isSafeInteger(expected) to be true"));
}

@@ -455,3 +661,3 @@ };

run(input) {
return Number.isFinite(input) ? Result.ok(input) : Result.err(new ConstraintError("numberFinite", `Expected number to be a finite number, but received ${input}`, input, "A finite number"));
return Number.isFinite(input) ? Result.ok(input) : Result.err(new ConstraintError("s.number.finite", "Given value is not finite", input, "Number.isFinite(expected) to be true"));
}

@@ -461,3 +667,3 @@ };

run(input) {
return Number.isNaN(input) ? Result.ok(input) : Result.err(new ConstraintError("numberNaN", `Expected number to be a NaN, but received ${input}`, input, "A NaN"));
return Number.isNaN(input) ? Result.ok(input) : Result.err(new ConstraintError("s.number.eq(NaN)", "Invalid number value", input, "expected === NaN"));
}

@@ -467,5 +673,14 @@ };

run(input) {
return Number.isNaN(input) ? Result.err(new ConstraintError("numberNeNaN", `Expected number to not be a NaN, but received ${input}`, input, "Not NaN")) : Result.ok(input);
return Number.isNaN(input) ? Result.err(new ConstraintError("s.number.ne(NaN)", "Invalid number value", input, "expected !== NaN")) : Result.ok(input);
}
};
function numberDivisibleBy(divider) {
const expected = `expected % ${divider} === 0`;
return {
run(input) {
return input % divider === 0 ? Result.ok(input) : Result.err(new ConstraintError("s.number.divisibleBy", "Number is not divisible", input, expected));
}
};
}
__name(numberDivisibleBy, "numberDivisibleBy");

@@ -507,2 +722,26 @@ // src/validators/NumberValidator.ts

}
divisibleBy(divider) {
return this.addConstraint(numberDivisibleBy(divider));
}
get abs() {
return this.transform(Math.abs);
}
get sign() {
return this.transform(Math.sign);
}
get trunc() {
return this.transform(Math.trunc);
}
get floor() {
return this.transform(Math.floor);
}
get fround() {
return this.transform(Math.fround);
}
get round() {
return this.transform(Math.round);
}
get ceil() {
return this.transform(Math.ceil);
}
handle(value) {

@@ -515,5 +754,5 @@ return typeof value === "number" ? Result.ok(value) : Result.err(new ValidationError("NumberValidator", "Expected a number primitive", value));

// src/lib/errors/MissingPropertyError.ts
var MissingPropertyError = class extends Error {
var MissingPropertyError = class extends BaseError {
constructor(property) {
super(`Expected property "${String(property)}" is missing`);
super("A required property is missing");
this.property = property;

@@ -527,2 +766,12 @@ }

}
[customInspectSymbolStackLess](depth, options) {
const property = options.stylize(this.property.toString(), "string");
if (depth < 0) {
return options.stylize(`[MissingPropertyError: ${property}]`, "special");
}
const header = `${options.stylize("MissingPropertyError", "special")} > ${property}`;
const message = options.stylize(this.message, "regexp");
return `${header}
${message}`;
}
};

@@ -532,5 +781,6 @@ __name(MissingPropertyError, "MissingPropertyError");

// src/lib/errors/UnknownPropertyError.ts
var UnknownPropertyError = class extends Error {
var import_node_util4 = __require("util");
var UnknownPropertyError = class extends BaseError {
constructor(property, value) {
super("Unknown property received");
super("Received unexpected property");
this.property = property;

@@ -546,2 +796,19 @@ this.value = value;

}
[customInspectSymbolStackLess](depth, options) {
const property = options.stylize(this.property.toString(), "string");
if (depth < 0) {
return options.stylize(`[UnknownPropertyError: ${property}]`, "special");
}
const newOptions = { ...options, depth: options.depth === null ? null : options.depth - 1, compact: true };
const padding = `
${options.stylize("|", "undefined")} `;
const given = (0, import_node_util4.inspect)(this.value, newOptions).replaceAll("\n", padding);
const header = `${options.stylize("UnknownPropertyError", "special")} > ${property}`;
const message = options.stylize(this.message, "regexp");
const givenBlock = `
${options.stylize("Received:", "regexp")}${padding}${given}`;
return `${header}
${message}
${givenBlock}`;
}
};

@@ -619,3 +886,3 @@ __name(UnknownPropertyError, "UnknownPropertyError");

}
return errors.length === 0 ? Result.ok(entries) : Result.err(new AggregateError(errors, "Failed to match at least one of the properties"));
return errors.length === 0 ? Result.ok(entries) : Result.err(new CombinedError(errors));
}

@@ -645,3 +912,3 @@ handleStrictStrategy(value) {

}
return errors.length === 0 ? Result.ok(finalResult) : Result.err(new AggregateError(errors, "Failed to match at least one of the properties"));
return errors.length === 0 ? Result.ok(finalResult) : Result.err(new CombinedError(errors));
}

@@ -689,3 +956,3 @@ };

}
return errors.length === 0 ? Result.ok(transformed) : Result.err(new AggregateError(errors, "Failed to validate at least one entry"));
return errors.length === 0 ? Result.ok(transformed) : Result.err(new CombinedError(errors));
}

@@ -706,3 +973,3 @@ };

if (!(values instanceof Set)) {
return Result.err(new ValidationError("ArrayValidator", "Expected an array", values));
return Result.err(new ValidationError("SetValidator", "Expected a set", values));
}

@@ -718,3 +985,3 @@ const errors = [];

}
return errors.length === 0 ? Result.ok(transformed) : Result.err(new AggregateError(errors, "Failed to validate at least one entry"));
return errors.length === 0 ? Result.ok(transformed) : Result.err(new CombinedError(errors));
}

@@ -725,29 +992,53 @@ };

// src/constraints/StringConstraints.ts
function stringLength(comparator, name, messageBuilder, length) {
function stringLengthComparator(comparator, name, expected, length) {
return {
run(input) {
return comparator(input.length, length) ? Result.ok(input) : Result.err(new ConstraintError(name, messageBuilder(input, length), input, length));
return comparator(input.length, length) ? Result.ok(input) : Result.err(new ConstraintError(name, "Invalid string length", input, expected));
}
};
}
__name(stringLength, "stringLength");
var stringLengthLt = stringLength.bind(null, lt, "stringLengthLt", (given, expected) => `Expected string to have less than ${expected} characters, but received one with ${given.length} characters`);
var stringLengthLe = stringLength.bind(null, le, "stringLengthLe", (given, expected) => `Expected string to have maximum ${expected} characters, but received one with ${given.length} characters`);
var stringLengthGt = stringLength.bind(null, gt, "stringLengthGt", (given, expected) => `Expected string to have more than ${expected} characters, but received one with ${given.length} characters`);
var stringLengthGe = stringLength.bind(null, ge, "stringLengthGe", (given, expected) => `Expected string to have at least ${expected} characters, but received one with ${given.length} characters`);
var stringLengthEq = stringLength.bind(null, eq, "stringLengthEq", (given, expected) => `Expected string to have exactly ${expected} characters, but received one with ${given.length} characters`);
var stringLengthNe = stringLength.bind(null, ne, "stringLengthNe", (given, expected) => `Expected string to not have exactly ${expected} characters, but received one with ${given.length} characters`);
__name(stringLengthComparator, "stringLengthComparator");
function stringLengthLt(length) {
const expected = `expected.length < ${length}`;
return stringLengthComparator(lt, "s.string.lengthLt", expected, length);
}
__name(stringLengthLt, "stringLengthLt");
function stringLengthLe(length) {
const expected = `expected.length <= ${length}`;
return stringLengthComparator(le, "s.string.lengthLe", expected, length);
}
__name(stringLengthLe, "stringLengthLe");
function stringLengthGt(length) {
const expected = `expected.length > ${length}`;
return stringLengthComparator(gt, "s.string.lengthGt", expected, length);
}
__name(stringLengthGt, "stringLengthGt");
function stringLengthGe(length) {
const expected = `expected.length >= ${length}`;
return stringLengthComparator(ge, "s.string.lengthGe", expected, length);
}
__name(stringLengthGe, "stringLengthGe");
function stringLengthEq(length) {
const expected = `expected.length === ${length}`;
return stringLengthComparator(eq, "s.string.lengthEq", expected, length);
}
__name(stringLengthEq, "stringLengthEq");
function stringLengthNe(length) {
const expected = `expected.length !== ${length}`;
return stringLengthComparator(ne, "s.string.lengthNe", expected, length);
}
__name(stringLengthNe, "stringLengthNe");
// src/validators/StringValidator.ts
var StringValidator = class extends BaseValidator {
lengthLe(length) {
lengthLt(length) {
return this.addConstraint(stringLengthLt(length));
}
lengthLte(length) {
lengthLe(length) {
return this.addConstraint(stringLengthLe(length));
}
lengthGe(length) {
lengthGt(length) {
return this.addConstraint(stringLengthGt(length));
}
lengthGte(length) {
lengthGe(length) {
return this.addConstraint(stringLengthGe(length));

@@ -826,3 +1117,3 @@ }

}
return Result.err(new AggregateError(errors, "Could not match any of the defined validators"));
return Result.err(new CombinedError(errors));
}

@@ -832,2 +1123,56 @@ };

// src/validators/MapValidator.ts
var MapValidator = class extends BaseValidator {
constructor(keyValidator, valueValidator, constraints = []) {
super(constraints);
this.keyValidator = keyValidator;
this.valueValidator = valueValidator;
}
clone() {
return Reflect.construct(this.constructor, [this.keyValidator, this.valueValidator, this.constraints]);
}
handle(value) {
if (!(value instanceof Map)) {
return Result.err(new ValidationError("MapValidator", "Expected a map", value));
}
const errors = [];
const transformed = /* @__PURE__ */ new Map();
for (const [key, val] of value.entries()) {
const keyResult = this.keyValidator.run(key);
const valueResult = this.valueValidator.run(val);
const { length } = errors;
if (keyResult.isErr())
errors.push(keyResult.error);
if (valueResult.isErr())
errors.push(valueResult.error);
if (errors.length === length)
transformed.set(keyResult.value, valueResult.value);
}
return errors.length === 0 ? Result.ok(transformed) : Result.err(new CombinedError(errors));
}
};
__name(MapValidator, "MapValidator");
// src/validators/util/getValue.ts
function getValue(valueOrFn) {
return typeof valueOrFn === "function" ? valueOrFn() : valueOrFn;
}
__name(getValue, "getValue");
// src/validators/DefaultValidator.ts
var DefaultValidator = class extends BaseValidator {
constructor(validator, value, constraints = []) {
super(constraints);
this.validator = validator;
this.defaultValue = value;
}
handle(value) {
return typeof value === "undefined" ? Result.ok(getValue(this.defaultValue)) : this.validator["handle"](value);
}
clone() {
return Reflect.construct(this.constructor, [this.validator, this.defaultValue, this.constraints]);
}
};
__name(DefaultValidator, "DefaultValidator");
// src/lib/Shapes.ts

@@ -894,2 +1239,5 @@ var Shapes = class {

}
map(keyValidator, valueValidator) {
return new MapValidator(keyValidator, valueValidator);
}
};

@@ -896,0 +1244,0 @@ __name(Shapes, "Shapes");

@@ -29,2 +29,3 @@ "use strict";

__export(src_exports, {
CombinedError: () => CombinedError,
ConstraintError: () => ConstraintError,

@@ -39,2 +40,32 @@ ExpectedValidationError: () => ExpectedValidationError,

// src/lib/Result.ts
var Result = class {
constructor(success, value, error) {
this.success = success;
if (success) {
this.value = value;
} else {
this.error = error;
}
}
isOk() {
return this.success;
}
isErr() {
return !this.success;
}
unwrap() {
if (this.isOk())
return this.value;
throw this.error;
}
static ok(value) {
return new Result(true, value);
}
static err(error) {
return new Result(false, void 0, error);
}
};
__name(Result, "Result");
// src/validators/BaseValidator.ts

@@ -64,2 +95,8 @@ var BaseValidator = class {

}
transform(cb) {
return this.addConstraint({ run: (input) => Result.ok(cb(input)) });
}
default(value) {
return new DefaultValidator(this.clone(), value);
}
run(value) {

@@ -90,4 +127,44 @@ let result = this.handle(value);

// src/lib/errors/BaseError.ts
var customInspectSymbol = Symbol.for("nodejs.util.inspect.custom");
var customInspectSymbolStackLess = Symbol.for("nodejs.util.inspect.custom.stack-less");
var BaseError = class extends Error {
[customInspectSymbol](depth, options) {
return `${this[customInspectSymbolStackLess](depth, options)}
${this.stack.slice(this.stack.indexOf("\n"))}`;
}
};
__name(BaseError, "BaseError");
// src/lib/errors/CombinedError.ts
var CombinedError = class extends BaseError {
constructor(errors) {
super("Received one or more errors");
this.errors = errors;
}
[customInspectSymbolStackLess](depth, options) {
if (depth < 0) {
return options.stylize("[CombinedError]", "special");
}
const newOptions = { ...options, depth: options.depth === null ? null : options.depth - 1, compact: true };
const padding = `
${options.stylize("|", "undefined")} `;
const header = `${options.stylize("CombinedError", "special")} (${options.stylize(this.errors.length.toString(), "number")})`;
const message = options.stylize(this.message, "regexp");
const errors = this.errors.map((error, i) => {
const index = options.stylize((i + 1).toString(), "number");
const body = error[customInspectSymbolStackLess](depth - 1, newOptions).replaceAll("\n", padding);
return ` ${index} ${body}`;
}).join("\n\n");
return `${header}
${message}
${errors}`;
}
};
__name(CombinedError, "CombinedError");
// src/lib/errors/ValidationError.ts
var ValidationError = class extends Error {
var import_node_util = require("util");
var ValidationError = class extends BaseError {
constructor(validator, message, given) {

@@ -105,34 +182,21 @@ super(message);

}
};
__name(ValidationError, "ValidationError");
// src/lib/Result.ts
var Result = class {
constructor(success, value, error) {
this.success = success;
if (success) {
this.value = value;
} else {
this.error = error;
[customInspectSymbolStackLess](depth, options) {
const validator = options.stylize(this.validator, "string");
if (depth < 0) {
return options.stylize(`[ValidationError: ${validator}]`, "special");
}
const newOptions = { ...options, depth: options.depth === null ? null : options.depth - 1, compact: true };
const padding = `
${options.stylize("|", "undefined")} `;
const given = (0, import_node_util.inspect)(this.given, newOptions).replaceAll("\n", padding);
const header = `${options.stylize("ValidationError", "special")} > ${validator}`;
const message = options.stylize(this.message, "regexp");
const givenBlock = `
${options.stylize("Received:", "regexp")}${padding}${given}`;
return `${header}
${message}
${givenBlock}`;
}
isOk() {
return this.success;
}
isErr() {
return !this.success;
}
unwrap() {
if (this.isOk())
return this.value;
throw this.error;
}
static ok(value) {
return new Result(true, value);
}
static err(error) {
return new Result(false, void 0, error);
}
};
__name(Result, "Result");
__name(ValidationError, "ValidationError");

@@ -161,3 +225,3 @@ // src/validators/ArrayValidator.ts

}
return errors.length === 0 ? Result.ok(transformed) : Result.err(new AggregateError(errors, "Failed to validate at least one entry"));
return errors.length === 0 ? Result.ok(transformed) : Result.err(new CombinedError(errors));
}

@@ -168,6 +232,7 @@ };

// src/lib/errors/ConstraintError.ts
var ConstraintError = class extends Error {
constructor(validator, message, given, expected) {
var import_node_util2 = require("util");
var ConstraintError = class extends BaseError {
constructor(constraint, message, given, expected) {
super(message);
this.constraint = validator;
this.constraint = constraint;
this.given = given;

@@ -184,2 +249,22 @@ this.expected = expected;

}
[customInspectSymbolStackLess](depth, options) {
const constraint = options.stylize(this.constraint, "string");
if (depth < 0) {
return options.stylize(`[ConstraintError: ${constraint}]`, "special");
}
const newOptions = { ...options, depth: options.depth === null ? null : options.depth - 1 };
const padding = `
${options.stylize("|", "undefined")} `;
const given = (0, import_node_util2.inspect)(this.given, newOptions).replaceAll("\n", padding);
const header = `${options.stylize("ConstraintError", "special")} > ${constraint}`;
const message = options.stylize(this.message, "regexp");
const expectedBlock = `
${options.stylize("Expected: ", "string")}${options.stylize(this.expected, "boolean")}`;
const givenBlock = `
${options.stylize("Received:", "regexp")}${padding}${given}`;
return `${header}
${message}
${expectedBlock}
${givenBlock}`;
}
};

@@ -202,3 +287,3 @@ __name(ConstraintError, "ConstraintError");

function ge(a, b) {
return a > b;
return a >= b;
}

@@ -216,6 +301,6 @@ __name(ge, "ge");

// src/constraints/BigIntConstraints.ts
function bigintComparator(comparator, name, messageBuilder, number) {
function bigintComparator(comparator, name, expected, number) {
return {
run(input) {
return comparator(input, number) ? Result.ok(input) : Result.err(new ConstraintError(name, messageBuilder(input, number), input, number));
return comparator(input, number) ? Result.ok(input) : Result.err(new ConstraintError(name, "Invalid bigint value", input, expected));
}

@@ -225,8 +310,41 @@ };

__name(bigintComparator, "bigintComparator");
var bigintLt = bigintComparator.bind(null, lt, "bigintLt", (given, expected) => `Expected bigint to be less than ${expected}, but received ${given}`);
var bigintLe = bigintComparator.bind(null, le, "bigintLe", (given, expected) => `Expected bigint to be less or equals than ${expected}, but received ${given}`);
var bigintGt = bigintComparator.bind(null, gt, "bigintGt", (given, expected) => `Expected bigint to be greater than ${expected}, but received ${given}`);
var bigintGe = bigintComparator.bind(null, ge, "bigintGe", (given, expected) => `Expected bigint to be greater or equals than ${expected}, but received ${given}`);
var bigintEq = bigintComparator.bind(null, eq, "bigintEq", (given, expected) => `Expected bigint to be exactly ${expected}, but received ${given}`);
var bigintNe = bigintComparator.bind(null, ne, "bigintNe", (_, expected) => `Expected bigint to not be ${expected}`);
function bigintLt(value) {
const expected = `expected < ${value}n`;
return bigintComparator(lt, "s.bigint.lt", expected, value);
}
__name(bigintLt, "bigintLt");
function bigintLe(value) {
const expected = `expected <= ${value}n`;
return bigintComparator(le, "s.bigint.le", expected, value);
}
__name(bigintLe, "bigintLe");
function bigintGt(value) {
const expected = `expected > ${value}n`;
return bigintComparator(gt, "s.bigint.gt", expected, value);
}
__name(bigintGt, "bigintGt");
function bigintGe(value) {
const expected = `expected >= ${value}n`;
return bigintComparator(ge, "s.bigint.ge", expected, value);
}
__name(bigintGe, "bigintGe");
function bigintEq(value) {
const expected = `expected === ${value}n`;
return bigintComparator(eq, "s.bigint.eq", expected, value);
}
__name(bigintEq, "bigintEq");
function bigintNe(value) {
const expected = `expected !== ${value}n`;
return bigintComparator(ne, "s.bigint.ne", expected, value);
}
__name(bigintNe, "bigintNe");
function bigintDivisibleBy(divider) {
const expected = `expected % ${divider}n === 0n`;
return {
run(input) {
return input % divider === 0n ? Result.ok(input) : Result.err(new ConstraintError("s.bigint.divisibleBy", "BigInt is not divisible", input, expected));
}
};
}
__name(bigintDivisibleBy, "bigintDivisibleBy");

@@ -259,2 +377,14 @@ // src/validators/BigIntValidator.ts

}
divisibleBy(number) {
return this.addConstraint(bigintDivisibleBy(number));
}
get abs() {
return this.transform((value) => value < 0 ? -value : value);
}
intN(bits) {
return this.transform((value) => BigInt.asIntN(bits, value));
}
uintN(bits) {
return this.transform((value) => BigInt.asUintN(bits, value));
}
handle(value) {

@@ -269,3 +399,3 @@ return typeof value === "bigint" ? Result.ok(value) : Result.err(new ValidationError("BigIntValidator", "Expected a bigint primitive", value));

run(input) {
return input ? Result.ok(input) : Result.err(new ConstraintError("booleanTrue", "Expected boolean to be true, but received false", input, true));
return input ? Result.ok(input) : Result.err(new ConstraintError("s.boolean.true", "Invalid boolean value", input, "true"));
}

@@ -275,3 +405,3 @@ };

run(input) {
return input ? Result.err(new ConstraintError("booleanFalse", "Expected boolean to be false, but received true", input, false)) : Result.ok(input);
return input ? Result.err(new ConstraintError("s.boolean.false", "Invalid boolean value", input, "false")) : Result.ok(input);
}

@@ -301,6 +431,6 @@ };

// src/constraints/DateConstraints.ts
function dateComparator(comparator, name, messageBuilder, date, number = date.getTime()) {
function dateComparator(comparator, name, expected, number) {
return {
run(input) {
return comparator(input.getTime(), number) ? Result.ok(input) : Result.err(new ConstraintError(name, messageBuilder(input, date), input, date));
return comparator(input.getTime(), number) ? Result.ok(input) : Result.err(new ConstraintError(name, "Invalid Date value", input, expected));
}

@@ -310,11 +440,35 @@ };

__name(dateComparator, "dateComparator");
var dateLt = dateComparator.bind(null, lt, "dateLt", (given, expected) => `Expected date to be earlier than ${expected}, but received ${given}`);
var dateLe = dateComparator.bind(null, le, "dateLe", (given, expected) => `Expected date to be earlier or equals than ${expected}, but received ${given}`);
var dateGt = dateComparator.bind(null, gt, "dateGt", (given, expected) => `Expected date to be later than ${expected}, but received ${given}`);
var dateGe = dateComparator.bind(null, ge, "dateGe", (given, expected) => `Expected date to be later or equals than ${expected}, but received ${given}`);
var dateEq = dateComparator.bind(null, eq, "dateEq", (given, expected) => `Expected date to be exactly ${expected}, but received ${given}`);
var dateNe = dateComparator.bind(null, ne, "dateNe", (_, expected) => `Expected date to not be ${expected}`);
function dateLt(value) {
const expected = `expected < ${value}`;
return dateComparator(lt, "s.date.lt", expected, value.getTime());
}
__name(dateLt, "dateLt");
function dateLe(value) {
const expected = `expected <= ${value}`;
return dateComparator(le, "s.date.le", expected, value.getTime());
}
__name(dateLe, "dateLe");
function dateGt(value) {
const expected = `expected > ${value}`;
return dateComparator(gt, "s.date.gt", expected, value.getTime());
}
__name(dateGt, "dateGt");
function dateGe(value) {
const expected = `expected >= ${value}`;
return dateComparator(ge, "s.date.ge", expected, value.getTime());
}
__name(dateGe, "dateGe");
function dateEq(value) {
const expected = `expected === ${value}`;
return dateComparator(eq, "s.date.eq", expected, value.getTime());
}
__name(dateEq, "dateEq");
function dateNe(value) {
const expected = `expected !== ${value}`;
return dateComparator(ne, "s.date.ne", expected, value.getTime());
}
__name(dateNe, "dateNe");
var dateInvalid = {
run(input) {
return Number.isNaN(input.getTime()) ? Result.ok(input) : Result.err(new ConstraintError("dateInvalid", `Expected Date's time to be a NaN, but received ${input}`, input, "An invalid Date"));
return Number.isNaN(input.getTime()) ? Result.ok(input) : Result.err(new ConstraintError("s.date.eq(NaN)", "Invalid Date value", input, "expected === NaN"));
}

@@ -324,3 +478,3 @@ };

run(input) {
return Number.isNaN(input.getTime()) ? Result.err(new ConstraintError("dateValid", `Expected Date's time to not be a NaN, but received ${input}`, input, "A valid Date")) : Result.ok(input);
return Number.isNaN(input.getTime()) ? Result.err(new ConstraintError("s.date.ne(NaN)", "Invalid Date value", input, "expected !== NaN")) : Result.ok(input);
}

@@ -358,2 +512,3 @@ };

// src/lib/errors/ExpectedValidationError.ts
var import_node_util3 = require("util");
var ExpectedValidationError = class extends ValidationError {

@@ -372,2 +527,23 @@ constructor(validator, message, given, expected) {

}
[customInspectSymbolStackLess](depth, options) {
const validator = options.stylize(this.validator, "string");
if (depth < 0) {
return options.stylize(`[ExpectedValidationError: ${validator}]`, "special");
}
const newOptions = { ...options, depth: options.depth === null ? null : options.depth - 1 };
const padding = `
${options.stylize("|", "undefined")} `;
const expected = (0, import_node_util3.inspect)(this.expected, newOptions).replaceAll("\n", padding);
const given = (0, import_node_util3.inspect)(this.given, newOptions).replaceAll("\n", padding);
const header = `${options.stylize("ExpectedValidationError", "special")} > ${validator}`;
const message = options.stylize(this.message, "regexp");
const expectedBlock = `
${options.stylize("Expected:", "string")}${padding}${expected}`;
const givenBlock = `
${options.stylize("Received:", "regexp")}${padding}${given}`;
return `${header}
${message}
${expectedBlock}
${givenBlock}`;
}
};

@@ -398,3 +574,3 @@ __name(ExpectedValidationError, "ExpectedValidationError");

handle(value) {
return Object.is(value, this.expected) ? Result.ok(value) : Result.err(new ExpectedValidationError("LiteralValidator", "Expected", value, this.expected));
return Object.is(value, this.expected) ? Result.ok(value) : Result.err(new ExpectedValidationError("LiteralValidator", "Expected values to be equals", value, this.expected));
}

@@ -424,6 +600,6 @@ clone() {

// src/constraints/NumberConstraints.ts
function numberComparator(comparator, name, messageBuilder, number) {
function numberComparator(comparator, name, expected, number) {
return {
run(input) {
return comparator(input, number) ? Result.ok(input) : Result.err(new ConstraintError(name, messageBuilder(input, number), input, number));
return comparator(input, number) ? Result.ok(input) : Result.err(new ConstraintError(name, "Invalid number value", input, expected));
}

@@ -433,11 +609,35 @@ };

__name(numberComparator, "numberComparator");
var numberLt = numberComparator.bind(null, lt, "numberLt", (given, expected) => `Expected number to be less than ${expected}, but received ${given}`);
var numberLe = numberComparator.bind(null, le, "numberLe", (given, expected) => `Expected number to be less or equals than ${expected}, but received ${given}`);
var numberGt = numberComparator.bind(null, gt, "numberGt", (given, expected) => `Expected number to be greater than ${expected}, but received ${given}`);
var numberGe = numberComparator.bind(null, ge, "numberGe", (given, expected) => `Expected number to be greater or equals than ${expected}, but received ${given}`);
var numberEq = numberComparator.bind(null, eq, "numberEq", (given, expected) => `Expected number to be exactly ${expected}, but received ${given}`);
var numberNe = numberComparator.bind(null, ne, "numberNe", (_, expected) => `Expected number to not be ${expected}`);
function numberLt(value) {
const expected = `expected < ${value}`;
return numberComparator(lt, "s.number.lt", expected, value);
}
__name(numberLt, "numberLt");
function numberLe(value) {
const expected = `expected <= ${value}`;
return numberComparator(le, "s.number.le", expected, value);
}
__name(numberLe, "numberLe");
function numberGt(value) {
const expected = `expected > ${value}`;
return numberComparator(gt, "s.number.gt", expected, value);
}
__name(numberGt, "numberGt");
function numberGe(value) {
const expected = `expected >= ${value}`;
return numberComparator(ge, "s.number.ge", expected, value);
}
__name(numberGe, "numberGe");
function numberEq(value) {
const expected = `expected === ${value}`;
return numberComparator(eq, "s.number.eq", expected, value);
}
__name(numberEq, "numberEq");
function numberNe(value) {
const expected = `expected !== ${value}`;
return numberComparator(ne, "s.number.ne", expected, value);
}
__name(numberNe, "numberNe");
var numberInt = {
run(input) {
return Number.isInteger(input) ? Result.ok(input) : Result.err(new ConstraintError("numberInt", `Expected number to be an integer, but received ${input}`, input, "An integer"));
return Number.isInteger(input) ? Result.ok(input) : Result.err(new ConstraintError("s.number.int", "Given value is not an integer", input, "Number.isInteger(expected) to be true"));
}

@@ -447,3 +647,3 @@ };

run(input) {
return Number.isSafeInteger(input) ? Result.ok(input) : Result.err(new ConstraintError("numberSafeInt", `Expected number to be a safe integer, but received ${input}`, input, "A safe integer"));
return Number.isSafeInteger(input) ? Result.ok(input) : Result.err(new ConstraintError("s.number.safeInt", "Given value is not a safe integer", input, "Number.isSafeInteger(expected) to be true"));
}

@@ -453,3 +653,3 @@ };

run(input) {
return Number.isFinite(input) ? Result.ok(input) : Result.err(new ConstraintError("numberFinite", `Expected number to be a finite number, but received ${input}`, input, "A finite number"));
return Number.isFinite(input) ? Result.ok(input) : Result.err(new ConstraintError("s.number.finite", "Given value is not finite", input, "Number.isFinite(expected) to be true"));
}

@@ -459,3 +659,3 @@ };

run(input) {
return Number.isNaN(input) ? Result.ok(input) : Result.err(new ConstraintError("numberNaN", `Expected number to be a NaN, but received ${input}`, input, "A NaN"));
return Number.isNaN(input) ? Result.ok(input) : Result.err(new ConstraintError("s.number.eq(NaN)", "Invalid number value", input, "expected === NaN"));
}

@@ -465,5 +665,14 @@ };

run(input) {
return Number.isNaN(input) ? Result.err(new ConstraintError("numberNeNaN", `Expected number to not be a NaN, but received ${input}`, input, "Not NaN")) : Result.ok(input);
return Number.isNaN(input) ? Result.err(new ConstraintError("s.number.ne(NaN)", "Invalid number value", input, "expected !== NaN")) : Result.ok(input);
}
};
function numberDivisibleBy(divider) {
const expected = `expected % ${divider} === 0`;
return {
run(input) {
return input % divider === 0 ? Result.ok(input) : Result.err(new ConstraintError("s.number.divisibleBy", "Number is not divisible", input, expected));
}
};
}
__name(numberDivisibleBy, "numberDivisibleBy");

@@ -505,2 +714,26 @@ // src/validators/NumberValidator.ts

}
divisibleBy(divider) {
return this.addConstraint(numberDivisibleBy(divider));
}
get abs() {
return this.transform(Math.abs);
}
get sign() {
return this.transform(Math.sign);
}
get trunc() {
return this.transform(Math.trunc);
}
get floor() {
return this.transform(Math.floor);
}
get fround() {
return this.transform(Math.fround);
}
get round() {
return this.transform(Math.round);
}
get ceil() {
return this.transform(Math.ceil);
}
handle(value) {

@@ -513,5 +746,5 @@ return typeof value === "number" ? Result.ok(value) : Result.err(new ValidationError("NumberValidator", "Expected a number primitive", value));

// src/lib/errors/MissingPropertyError.ts
var MissingPropertyError = class extends Error {
var MissingPropertyError = class extends BaseError {
constructor(property) {
super(`Expected property "${String(property)}" is missing`);
super("A required property is missing");
this.property = property;

@@ -525,2 +758,12 @@ }

}
[customInspectSymbolStackLess](depth, options) {
const property = options.stylize(this.property.toString(), "string");
if (depth < 0) {
return options.stylize(`[MissingPropertyError: ${property}]`, "special");
}
const header = `${options.stylize("MissingPropertyError", "special")} > ${property}`;
const message = options.stylize(this.message, "regexp");
return `${header}
${message}`;
}
};

@@ -530,5 +773,6 @@ __name(MissingPropertyError, "MissingPropertyError");

// src/lib/errors/UnknownPropertyError.ts
var UnknownPropertyError = class extends Error {
var import_node_util4 = require("util");
var UnknownPropertyError = class extends BaseError {
constructor(property, value) {
super("Unknown property received");
super("Received unexpected property");
this.property = property;

@@ -544,2 +788,19 @@ this.value = value;

}
[customInspectSymbolStackLess](depth, options) {
const property = options.stylize(this.property.toString(), "string");
if (depth < 0) {
return options.stylize(`[UnknownPropertyError: ${property}]`, "special");
}
const newOptions = { ...options, depth: options.depth === null ? null : options.depth - 1, compact: true };
const padding = `
${options.stylize("|", "undefined")} `;
const given = (0, import_node_util4.inspect)(this.value, newOptions).replaceAll("\n", padding);
const header = `${options.stylize("UnknownPropertyError", "special")} > ${property}`;
const message = options.stylize(this.message, "regexp");
const givenBlock = `
${options.stylize("Received:", "regexp")}${padding}${given}`;
return `${header}
${message}
${givenBlock}`;
}
};

@@ -617,3 +878,3 @@ __name(UnknownPropertyError, "UnknownPropertyError");

}
return errors.length === 0 ? Result.ok(entries) : Result.err(new AggregateError(errors, "Failed to match at least one of the properties"));
return errors.length === 0 ? Result.ok(entries) : Result.err(new CombinedError(errors));
}

@@ -643,3 +904,3 @@ handleStrictStrategy(value) {

}
return errors.length === 0 ? Result.ok(finalResult) : Result.err(new AggregateError(errors, "Failed to match at least one of the properties"));
return errors.length === 0 ? Result.ok(finalResult) : Result.err(new CombinedError(errors));
}

@@ -687,3 +948,3 @@ };

}
return errors.length === 0 ? Result.ok(transformed) : Result.err(new AggregateError(errors, "Failed to validate at least one entry"));
return errors.length === 0 ? Result.ok(transformed) : Result.err(new CombinedError(errors));
}

@@ -704,3 +965,3 @@ };

if (!(values instanceof Set)) {
return Result.err(new ValidationError("ArrayValidator", "Expected an array", values));
return Result.err(new ValidationError("SetValidator", "Expected a set", values));
}

@@ -716,3 +977,3 @@ const errors = [];

}
return errors.length === 0 ? Result.ok(transformed) : Result.err(new AggregateError(errors, "Failed to validate at least one entry"));
return errors.length === 0 ? Result.ok(transformed) : Result.err(new CombinedError(errors));
}

@@ -723,29 +984,53 @@ };

// src/constraints/StringConstraints.ts
function stringLength(comparator, name, messageBuilder, length) {
function stringLengthComparator(comparator, name, expected, length) {
return {
run(input) {
return comparator(input.length, length) ? Result.ok(input) : Result.err(new ConstraintError(name, messageBuilder(input, length), input, length));
return comparator(input.length, length) ? Result.ok(input) : Result.err(new ConstraintError(name, "Invalid string length", input, expected));
}
};
}
__name(stringLength, "stringLength");
var stringLengthLt = stringLength.bind(null, lt, "stringLengthLt", (given, expected) => `Expected string to have less than ${expected} characters, but received one with ${given.length} characters`);
var stringLengthLe = stringLength.bind(null, le, "stringLengthLe", (given, expected) => `Expected string to have maximum ${expected} characters, but received one with ${given.length} characters`);
var stringLengthGt = stringLength.bind(null, gt, "stringLengthGt", (given, expected) => `Expected string to have more than ${expected} characters, but received one with ${given.length} characters`);
var stringLengthGe = stringLength.bind(null, ge, "stringLengthGe", (given, expected) => `Expected string to have at least ${expected} characters, but received one with ${given.length} characters`);
var stringLengthEq = stringLength.bind(null, eq, "stringLengthEq", (given, expected) => `Expected string to have exactly ${expected} characters, but received one with ${given.length} characters`);
var stringLengthNe = stringLength.bind(null, ne, "stringLengthNe", (given, expected) => `Expected string to not have exactly ${expected} characters, but received one with ${given.length} characters`);
__name(stringLengthComparator, "stringLengthComparator");
function stringLengthLt(length) {
const expected = `expected.length < ${length}`;
return stringLengthComparator(lt, "s.string.lengthLt", expected, length);
}
__name(stringLengthLt, "stringLengthLt");
function stringLengthLe(length) {
const expected = `expected.length <= ${length}`;
return stringLengthComparator(le, "s.string.lengthLe", expected, length);
}
__name(stringLengthLe, "stringLengthLe");
function stringLengthGt(length) {
const expected = `expected.length > ${length}`;
return stringLengthComparator(gt, "s.string.lengthGt", expected, length);
}
__name(stringLengthGt, "stringLengthGt");
function stringLengthGe(length) {
const expected = `expected.length >= ${length}`;
return stringLengthComparator(ge, "s.string.lengthGe", expected, length);
}
__name(stringLengthGe, "stringLengthGe");
function stringLengthEq(length) {
const expected = `expected.length === ${length}`;
return stringLengthComparator(eq, "s.string.lengthEq", expected, length);
}
__name(stringLengthEq, "stringLengthEq");
function stringLengthNe(length) {
const expected = `expected.length !== ${length}`;
return stringLengthComparator(ne, "s.string.lengthNe", expected, length);
}
__name(stringLengthNe, "stringLengthNe");
// src/validators/StringValidator.ts
var StringValidator = class extends BaseValidator {
lengthLe(length) {
lengthLt(length) {
return this.addConstraint(stringLengthLt(length));
}
lengthLte(length) {
lengthLe(length) {
return this.addConstraint(stringLengthLe(length));
}
lengthGe(length) {
lengthGt(length) {
return this.addConstraint(stringLengthGt(length));
}
lengthGte(length) {
lengthGe(length) {
return this.addConstraint(stringLengthGe(length));

@@ -824,3 +1109,3 @@ }

}
return Result.err(new AggregateError(errors, "Could not match any of the defined validators"));
return Result.err(new CombinedError(errors));
}

@@ -830,2 +1115,56 @@ };

// src/validators/MapValidator.ts
var MapValidator = class extends BaseValidator {
constructor(keyValidator, valueValidator, constraints = []) {
super(constraints);
this.keyValidator = keyValidator;
this.valueValidator = valueValidator;
}
clone() {
return Reflect.construct(this.constructor, [this.keyValidator, this.valueValidator, this.constraints]);
}
handle(value) {
if (!(value instanceof Map)) {
return Result.err(new ValidationError("MapValidator", "Expected a map", value));
}
const errors = [];
const transformed = /* @__PURE__ */ new Map();
for (const [key, val] of value.entries()) {
const keyResult = this.keyValidator.run(key);
const valueResult = this.valueValidator.run(val);
const { length } = errors;
if (keyResult.isErr())
errors.push(keyResult.error);
if (valueResult.isErr())
errors.push(valueResult.error);
if (errors.length === length)
transformed.set(keyResult.value, valueResult.value);
}
return errors.length === 0 ? Result.ok(transformed) : Result.err(new CombinedError(errors));
}
};
__name(MapValidator, "MapValidator");
// src/validators/util/getValue.ts
function getValue(valueOrFn) {
return typeof valueOrFn === "function" ? valueOrFn() : valueOrFn;
}
__name(getValue, "getValue");
// src/validators/DefaultValidator.ts
var DefaultValidator = class extends BaseValidator {
constructor(validator, value, constraints = []) {
super(constraints);
this.validator = validator;
this.defaultValue = value;
}
handle(value) {
return typeof value === "undefined" ? Result.ok(getValue(this.defaultValue)) : this.validator["handle"](value);
}
clone() {
return Reflect.construct(this.constructor, [this.validator, this.defaultValue, this.constraints]);
}
};
__name(DefaultValidator, "DefaultValidator");
// src/lib/Shapes.ts

@@ -892,2 +1231,5 @@ var Shapes = class {

}
map(keyValidator, valueValidator) {
return new MapValidator(keyValidator, valueValidator);
}
};

@@ -901,2 +1243,3 @@ __name(Shapes, "Shapes");

0 && (module.exports = {
CombinedError,
ConstraintError,

@@ -903,0 +1246,0 @@ ExpectedValidationError,

{
"name": "@sapphire/shapeshift",
"version": "1.1.0-next.8727427.0",
"version": "1.1.0-next.18d20d1.0",
"description": "Blazing fast input validation and transformation ⚡",

@@ -33,21 +33,21 @@ "author": "@sapphire",

"devDependencies": {
"@commitlint/cli": "^16.1.0",
"@commitlint/config-conventional": "^16.0.0",
"@commitlint/cli": "^16.2.1",
"@commitlint/config-conventional": "^16.2.1",
"@favware/npm-deprecate": "^1.0.4",
"@favware/rollup-type-bundler": "^1.0.7",
"@sapphire/eslint-config": "^4.0.11",
"@sapphire/prettier-config": "^1.2.9",
"@sapphire/ts-config": "^3.1.8",
"@sapphire/eslint-config": "^4.2.0",
"@sapphire/prettier-config": "^1.3.0",
"@sapphire/ts-config": "^3.3.1",
"@types/jest": "^27.4.0",
"@types/node": "^17.0.8",
"@typescript-eslint/eslint-plugin": "^5.10.0",
"@typescript-eslint/parser": "^5.10.0",
"@typescript-eslint/eslint-plugin": "^5.11.0",
"@typescript-eslint/parser": "^5.11.0",
"cz-conventional-changelog": "^3.3.0",
"eslint": "~8.7.0",
"eslint": "~8.9.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"husky": "^7.0.4",
"jest": "^27.4.7",
"jest-circus": "^27.4.6",
"lint-staged": "^12.2.2",
"jest": "^27.5.1",
"jest-circus": "^27.5.1",
"lint-staged": "^12.3.3",
"prettier": "^2.5.1",

@@ -57,6 +57,6 @@ "pretty-quick": "^3.1.3",

"ts-jest": "^27.1.3",
"ts-node": "^10.4.0",
"tsup": "^5.11.11",
"ts-node": "^10.5.0",
"tsup": "^5.11.13",
"typedoc": "^0.22.11",
"typedoc-plugin-mdn-links": "^1.0.4",
"typedoc-plugin-mdn-links": "^1.0.5",
"typescript": "^4.5.5"

@@ -63,0 +63,0 @@ },

@@ -135,3 +135,3 @@ <div align="center">

s.number.divisibleBy(5); // TODO | Divisible by 5
s.number.divisibleBy(5); // Divisible by 5
```

@@ -142,10 +142,10 @@

```typescript
s.number.abs; // TODO | Transforms the number to an absolute number
s.number.sign; // TODO | Gets the number's sign
s.number.abs; // Transforms the number to an absolute number
s.number.sign; // Gets the number's sign
s.number.trunc; // TODO | Transforms the number to the result of Math.trunc`
s.number.floor; // TODO | Transforms the number to the result of Math.floor`
s.number.fround; // TODO | Transforms the number to the result of Math.fround`
s.number.round; // TODO | Transforms the number to the result of Math.round`
s.number.ceil; // TODO | Transforms the number to the result of Math.ceil`
s.number.trunc; // Transforms the number to the result of `Math.trunc`
s.number.floor; // Transforms the number to the result of `Math.floor`
s.number.fround; // Transforms the number to the result of `Math.fround`
s.number.round; // Transforms the number to the result of `Math.round`
s.number.ceil; // Transforms the number to the result of `Math.ceil`
```

@@ -168,3 +168,3 @@

s.bigint.divisibleBy(5n); // TODO | Divisible by 5n
s.bigint.divisibleBy(5n); // Divisible by 5n
```

@@ -175,6 +175,6 @@

```typescript
s.bigint.abs; // TODO | Transforms the bigint to an absolute bigint
s.bigint.abs; // Transforms the bigint to an absolute bigint
s.bigint.intN(5); // TODO | Clamps to a bigint to a signed bigint with 5 digits, see BigInt.asIntN
s.bigint.uintN(5); // TODO | Clamps to a bigint to an unsigned bigint with 5 digits, see BigInt.asUintN
s.bigint.intN(5); // Clamps to a bigint to a signed bigint with 5 digits, see BigInt.asIntN
s.bigint.uintN(5); // Clamps to a bigint to an unsigned bigint with 5 digits, see BigInt.asUintN
```

@@ -343,3 +343,3 @@

tags.parse({ foo: 'bar', hello: 'world' }); // => { foo: 'bar', hello: 'world' }
tags.parse({ foo: 42 }); // => throws AggregateError
tags.parse({ foo: 42 }); // => throws CombinedError
tags.parse('Hello'); // => throws ValidateError

@@ -357,3 +357,3 @@ ```

stringOrNumber.parse(42); // => 42
stringOrNumber.parse({}); // => throws AggregateError
stringOrNumber.parse({}); // => throws CombinedError
```

@@ -370,3 +370,3 @@

#### Maps // TODO
#### Maps

@@ -429,3 +429,3 @@ ```typescript

const getLength = s.string.transform((value) => value.length); // TODO
const getLength = s.string.transform((value) => value.length);
getLength.parse('Hello There'); // => 11

@@ -450,3 +450,3 @@ ```

```typescript
const name = s.string.default('Sapphire'); // TODO
const name = s.string.default('Sapphire');
name.parse('Hello'); // => 'Hello'

@@ -457,3 +457,3 @@ name.parse(undefined); // => 'Sapphire'

```typescript
const number = s.number.default(Math.random); // TODO
const number = s.number.default(Math.random);
number.parse(12); // => 12

@@ -527,2 +527,3 @@ number.parse(undefined); // => 0.989911985608602

<td align="center"><a href="https://renovate.whitesourcesoftware.com/"><img src="https://avatars.githubusercontent.com/u/25180681?v=4?s=100" width="100px;" alt=""/><br /><sub><b>WhiteSource Renovate</b></sub></a><br /><a href="#maintenance-renovate-bot" title="Maintenance">🚧</a></td>
<td align="center"><a href="https://github.com/Khasms"><img src="https://avatars.githubusercontent.com/u/36800359?v=4?s=100" width="100px;" alt=""/><br /><sub><b>John</b></sub></a><br /><a href="https://github.com/sapphiredev/shapeshift/commits?author=Khasms" title="Code">💻</a></td>
</tr>

@@ -529,0 +530,0 @@ </table>

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc