valgen 6.0.3 → 6.1.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/constants.js CHANGED
@@ -1,4 +1,4 @@
1
- export const version = '6.0.3';
1
+ export const version = '6.1.0';
2
2
  export const postValidation = Symbol('postValidation');
3
3
  export const preValidation = Symbol('preValidation');
4
4
  export const VALIDATE_METADATA = Symbol('VALIDATE_METADATA');
@@ -1,3 +1,4 @@
1
+ import {} from './types.js';
1
2
  export class ValidationError extends Error {
2
3
  issues = [];
3
4
  constructor(issues) {
package/index.d.ts CHANGED
@@ -1,70 +1,72 @@
1
- import { Context, ExecutionOptions } from './core/index.js';
1
+ import type { Type } from 'ts-gems';
2
+ import { Context, type ExecutionOptions, type Validator } from './core/index.js';
2
3
  import * as vg from './rules/index.js';
3
4
  export * from './constants.js';
4
5
  export * from './core/index.js';
5
- declare const isAlpha: import("./core/validator.js").Validator<string, string, ExecutionOptions>;
6
- declare const isAlphanumeric: import("./core/validator.js").Validator<string, string, ExecutionOptions>;
7
- declare const isAny: import("./core/validator.js").Validator<any, any, ExecutionOptions>;
8
- declare const isArray: import("./core/validator.js").Validator<unknown[], unknown, ExecutionOptions>;
9
- declare const isAscii: import("./core/validator.js").Validator<string, string, ExecutionOptions>;
10
- declare const isBase64: import("./core/validator.js").Validator<string, string, ExecutionOptions>;
11
- declare const isBigint: import("./core/validator.js").Validator<bigint, unknown, ExecutionOptions>;
12
- declare const isBoolean: import("./core/validator.js").Validator<boolean | undefined, unknown, ExecutionOptions>;
13
- declare const isBtcAddress: import("./core/validator.js").Validator<string, string, ExecutionOptions>;
14
- declare const isCreditCard: import("./core/validator.js").Validator<string, string, ExecutionOptions>;
15
- declare const isDate: import("./core/validator.js").Validator<Date, string | number | Date, ExecutionOptions>;
16
- declare const isDateString: import("./core/validator.js").Validator<string, string | number | Date, ExecutionOptions>;
17
- declare const isDecimal: import("./core/validator.js").Validator<string, string, ExecutionOptions>;
18
- declare const isDefined: import("./core/validator.js").Validator<any, unknown, ExecutionOptions>;
19
- declare const isEAN: import("./core/validator.js").Validator<string, string, ExecutionOptions>;
20
- declare const isEmail: import("./core/validator.js").Validator<string, string, ExecutionOptions>;
21
- declare const isEmpty: import("./core/validator.js").Validator<any, any, ExecutionOptions>;
22
- declare const isETHAddress: import("./core/validator.js").Validator<string, string, ExecutionOptions>;
23
- declare const isFQDN: import("./core/validator.js").Validator<string, string, ExecutionOptions>;
24
- declare const isHex: import("./core/validator.js").Validator<string, string, ExecutionOptions>;
25
- declare const isHexColor: import("./core/validator.js").Validator<string, string, ExecutionOptions>;
26
- declare const isIBAN: import("./core/validator.js").Validator<string, string, ExecutionOptions>;
27
- declare const isInteger: import("./core/validator.js").Validator<number, unknown, ExecutionOptions>;
28
- declare const isIP: import("./core/validator.js").Validator<string, string, ExecutionOptions>;
29
- declare const isIPRange: import("./core/validator.js").Validator<string, string, ExecutionOptions>;
30
- declare const isISSN: import("./core/validator.js").Validator<string, string, ExecutionOptions>;
31
- declare const isJWT: import("./core/validator.js").Validator<string, string, ExecutionOptions>;
32
- declare const isLowercase: import("./core/validator.js").Validator<string, string, ExecutionOptions>;
33
- declare const isMACAddress: import("./core/validator.js").Validator<string, string, ExecutionOptions>;
34
- declare const isMobilePhone: import("./core/validator.js").Validator<string, string, ExecutionOptions>;
35
- declare const isNotEmpty: import("./core/validator.js").Validator<any, any, ExecutionOptions>;
36
- declare const isNotNull: import("./core/validator.js").Validator<unknown, unknown, ExecutionOptions>;
37
- declare const isNotNullish: import("./core/validator.js").Validator<unknown, unknown, ExecutionOptions>;
38
- declare const isNull: import("./core/validator.js").Validator<null, unknown, ExecutionOptions>;
39
- declare const isNullish: import("./core/validator.js").Validator<null, unknown, ExecutionOptions>;
40
- declare const isNumber: import("./core/validator.js").Validator<number, unknown, ExecutionOptions>;
6
+ declare const isAlpha: Validator<string, string, ExecutionOptions>;
7
+ declare const isAlphanumeric: Validator<string, string, ExecutionOptions>;
8
+ declare const isAny: Validator<any, any, ExecutionOptions>;
9
+ declare const isArray: Validator<unknown[], unknown, ExecutionOptions>;
10
+ declare const isAscii: Validator<string, string, ExecutionOptions>;
11
+ declare const isBase64: Validator<string, string, ExecutionOptions>;
12
+ declare const isBigint: Validator<bigint, unknown, ExecutionOptions>;
13
+ declare const isBoolean: Validator<boolean | undefined, unknown, ExecutionOptions>;
14
+ declare const isBtcAddress: Validator<string, string, ExecutionOptions>;
15
+ declare const isCreditCard: Validator<string, string, ExecutionOptions>;
16
+ declare const isDate: Validator<Date, string | number | Date, ExecutionOptions>;
17
+ declare const isDateString: Validator<string, string | number | Date, ExecutionOptions>;
18
+ declare const isDecimal: Validator<string, string, ExecutionOptions>;
19
+ declare const isDefined: Validator<any, unknown, ExecutionOptions>;
20
+ declare const isEAN: Validator<string, string, ExecutionOptions>;
21
+ declare const isEmail: Validator<string, string, ExecutionOptions>;
22
+ declare const isEmpty: Validator<any, any, ExecutionOptions>;
23
+ declare const isETHAddress: Validator<string, string, ExecutionOptions>;
24
+ declare const isFQDN: Validator<string, string, ExecutionOptions>;
25
+ declare const isHex: Validator<string, string, ExecutionOptions>;
26
+ declare const isHexColor: Validator<string, string, ExecutionOptions>;
27
+ declare const isIBAN: Validator<string, string, ExecutionOptions>;
28
+ declare const isInteger: Validator<number, unknown, ExecutionOptions>;
29
+ declare const isInstanceOf: <T extends object>(clazz: Type<T>, input: any, options?: vg.isInstanceOf.Options) => any;
30
+ declare const isIP: Validator<string, string, ExecutionOptions>;
31
+ declare const isIPRange: Validator<string, string, ExecutionOptions>;
32
+ declare const isISSN: Validator<string, string, ExecutionOptions>;
33
+ declare const isJWT: Validator<string, string, ExecutionOptions>;
34
+ declare const isLowercase: Validator<string, string, ExecutionOptions>;
35
+ declare const isMACAddress: Validator<string, string, ExecutionOptions>;
36
+ declare const isMobilePhone: Validator<string, string, ExecutionOptions>;
37
+ declare const isNotEmpty: Validator<any, any, ExecutionOptions>;
38
+ declare const isNotNull: Validator<unknown, unknown, ExecutionOptions>;
39
+ declare const isNotNullish: Validator<unknown, unknown, ExecutionOptions>;
40
+ declare const isNull: Validator<null, unknown, ExecutionOptions>;
41
+ declare const isNullish: Validator<null, unknown, ExecutionOptions>;
42
+ declare const isNumber: Validator<number, unknown, ExecutionOptions>;
41
43
  declare const isObject: vg.isObject.Validator<object, string | object>;
42
- declare const isObjectId: import("./core/validator.js").Validator<string | Uint8Array<ArrayBufferLike> | vg.isObjectId.ObjectIdLike, unknown, ExecutionOptions>;
43
- declare const isPort: import("./core/validator.js").Validator<number, string | number, ExecutionOptions>;
44
- declare const isString: import("./core/validator.js").Validator<string, unknown, ExecutionOptions>;
45
- declare const isSWIFT: import("./core/validator.js").Validator<string, string, ExecutionOptions>;
46
- declare const isTime: import("./core/validator.js").Validator<string, string | Date, ExecutionOptions>;
47
- declare const isUndefined: import("./core/validator.js").Validator<any, unknown, ExecutionOptions>;
48
- declare const isUppercase: import("./core/validator.js").Validator<string, string, ExecutionOptions>;
49
- declare const isURL: import("./core/validator.js").Validator<string, string, ExecutionOptions>;
50
- declare const isUUID: import("./core/validator.js").Validator<string, string, ExecutionOptions>;
51
- declare const isUUID1: import("./core/validator.js").Validator<string, string, ExecutionOptions>;
52
- declare const isUUID2: import("./core/validator.js").Validator<string, string, ExecutionOptions>;
53
- declare const isUUID3: import("./core/validator.js").Validator<string, string, ExecutionOptions>;
54
- declare const isUUID4: import("./core/validator.js").Validator<string, string, ExecutionOptions>;
55
- declare const isUUID5: import("./core/validator.js").Validator<string, string, ExecutionOptions>;
56
- declare const isUUID6: import("./core/validator.js").Validator<string, string, ExecutionOptions>;
57
- declare const isUUID7: import("./core/validator.js").Validator<string, string, ExecutionOptions>;
58
- declare const isUUID8: import("./core/validator.js").Validator<string, string, ExecutionOptions>;
59
- declare const toArray: import("./core/validator.js").Validator<any[], any, ExecutionOptions>;
60
- declare const toBigint: import("./core/validator.js").Validator<bigint, unknown, ExecutionOptions>;
61
- declare const toBoolean: import("./core/validator.js").Validator<boolean | undefined, unknown, ExecutionOptions>;
62
- declare const toDate: import("./core/validator.js").Validator<Date, string | number | Date, ExecutionOptions>;
44
+ declare const isObjectId: Validator<string | Uint8Array<ArrayBufferLike> | vg.isObjectId.ObjectIdLike, unknown, ExecutionOptions>;
45
+ declare const isPort: Validator<number, string | number, ExecutionOptions>;
46
+ declare const isString: Validator<string, unknown, ExecutionOptions>;
47
+ declare const isSWIFT: Validator<string, string, ExecutionOptions>;
48
+ declare const isTime: Validator<string, string | Date, ExecutionOptions>;
49
+ declare const isUndefined: Validator<any, unknown, ExecutionOptions>;
50
+ declare const isUppercase: Validator<string, string, ExecutionOptions>;
51
+ declare const isURL: Validator<string, string, ExecutionOptions>;
52
+ declare const isUUID: Validator<string, string, ExecutionOptions>;
53
+ declare const isUUID1: Validator<string, string, ExecutionOptions>;
54
+ declare const isUUID2: Validator<string, string, ExecutionOptions>;
55
+ declare const isUUID3: Validator<string, string, ExecutionOptions>;
56
+ declare const isUUID4: Validator<string, string, ExecutionOptions>;
57
+ declare const isUUID5: Validator<string, string, ExecutionOptions>;
58
+ declare const isUUID6: Validator<string, string, ExecutionOptions>;
59
+ declare const isUUID7: Validator<string, string, ExecutionOptions>;
60
+ declare const isUUID8: Validator<string, string, ExecutionOptions>;
61
+ declare const toArray: Validator<any[], any, ExecutionOptions>;
62
+ declare const toBigint: Validator<bigint, unknown, ExecutionOptions>;
63
+ declare const toBoolean: Validator<boolean | undefined, unknown, ExecutionOptions>;
64
+ declare const toDate: Validator<Date, string | number | Date, ExecutionOptions>;
63
65
  declare const toDateString: (input: Date | string | number, options?: ExecutionOptions & {
64
66
  trim?: vg.isDateString.Precision;
65
67
  }, ctx?: Context) => any;
66
- declare const toInteger: import("./core/validator.js").Validator<number, unknown, ExecutionOptions>;
67
- declare const toNumber: import("./core/validator.js").Validator<number, unknown, ExecutionOptions>;
68
- declare const toString: import("./core/validator.js").Validator<string, unknown, ExecutionOptions>;
69
- declare const toTime: import("./core/validator.js").Validator<string, string | Date, ExecutionOptions>;
70
- export { isAlpha, isAlphanumeric, isAny, isArray, isAscii, isBase64, isBigint, isBoolean, isBtcAddress, isCreditCard, isDate, isDateString, isDecimal, isDefined, isEAN, isEmail, isEmpty, isETHAddress, isFQDN, isHex, isHexColor, isIBAN, isInteger, isIP, isIPRange, isISSN, isJWT, isLowercase, isMACAddress, isMobilePhone, isNotEmpty, isNotNull, isNotNullish, isNull, isNullish, isNumber, isObject, isObjectId, isPort, isString, isSWIFT, isTime, isUndefined, isUppercase, isURL, isUUID, isUUID1, isUUID2, isUUID3, isUUID4, isUUID5, isUUID6, isUUID7, isUUID8, toArray, toBigint, toBoolean, toDate, toDateString, toInteger, toNumber, toString, toTime, vg, };
68
+ declare const toInteger: Validator<number, unknown, ExecutionOptions>;
69
+ declare const toNumber: Validator<number, unknown, ExecutionOptions>;
70
+ declare const toString: Validator<string, unknown, ExecutionOptions>;
71
+ declare const toTime: Validator<string, string | Date, ExecutionOptions>;
72
+ export { isAlpha, isAlphanumeric, isAny, isArray, isAscii, isBase64, isBigint, isBoolean, isBtcAddress, isCreditCard, isDate, isDateString, isDecimal, isDefined, isEAN, isEmail, isEmpty, isETHAddress, isFQDN, isHex, isHexColor, isIBAN, isInstanceOf, isInteger, isIP, isIPRange, isISSN, isJWT, isLowercase, isMACAddress, isMobilePhone, isNotEmpty, isNotNull, isNotNullish, isNull, isNullish, isNumber, isObject, isObjectId, isPort, isString, isSWIFT, isTime, isUndefined, isUppercase, isURL, isUUID, isUUID1, isUUID2, isUUID3, isUUID4, isUUID5, isUUID6, isUUID7, isUUID8, toArray, toBigint, toBoolean, toDate, toDateString, toInteger, toNumber, toString, toTime, vg, };
package/index.js CHANGED
@@ -1,6 +1,8 @@
1
+ import { Context, } from './core/index.js';
1
2
  import * as vg from './rules/index.js';
2
3
  export * from './constants.js';
3
4
  export * from './core/index.js';
5
+ const isInstanceOfCache = new WeakMap();
4
6
  const isAlpha = vg.isAlpha();
5
7
  const isAlphanumeric = vg.isAlphanumeric();
6
8
  const isAny = vg.isAny();
@@ -24,6 +26,14 @@ const isHex = vg.isHex();
24
26
  const isHexColor = vg.isHexColor();
25
27
  const isIBAN = vg.isIBAN();
26
28
  const isInteger = vg.isInteger();
29
+ const isInstanceOf = (clazz, input, options) => {
30
+ let fn = isInstanceOfCache.get(clazz);
31
+ if (!fn) {
32
+ fn = vg.isInstanceOf(clazz);
33
+ isInstanceOfCache.set(clazz, fn);
34
+ }
35
+ return fn(input, options);
36
+ };
27
37
  const isIP = vg.isIP();
28
38
  const isIPRange = vg.isIPRange();
29
39
  const isISSN = vg.isISSN();
@@ -77,4 +87,4 @@ const toInteger = vg.isInteger({ coerce: true });
77
87
  const toNumber = vg.isNumber({ coerce: true });
78
88
  const toString = vg.isString({ coerce: true });
79
89
  const toTime = vg.isTime({ coerce: true });
80
- export { isAlpha, isAlphanumeric, isAny, isArray, isAscii, isBase64, isBigint, isBoolean, isBtcAddress, isCreditCard, isDate, isDateString, isDecimal, isDefined, isEAN, isEmail, isEmpty, isETHAddress, isFQDN, isHex, isHexColor, isIBAN, isInteger, isIP, isIPRange, isISSN, isJWT, isLowercase, isMACAddress, isMobilePhone, isNotEmpty, isNotNull, isNotNullish, isNull, isNullish, isNumber, isObject, isObjectId, isPort, isString, isSWIFT, isTime, isUndefined, isUppercase, isURL, isUUID, isUUID1, isUUID2, isUUID3, isUUID4, isUUID5, isUUID6, isUUID7, isUUID8, toArray, toBigint, toBoolean, toDate, toDateString, toInteger, toNumber, toString, toTime, vg, };
90
+ export { isAlpha, isAlphanumeric, isAny, isArray, isAscii, isBase64, isBigint, isBoolean, isBtcAddress, isCreditCard, isDate, isDateString, isDecimal, isDefined, isEAN, isEmail, isEmpty, isETHAddress, isFQDN, isHex, isHexColor, isIBAN, isInstanceOf, isInteger, isIP, isIPRange, isISSN, isJWT, isLowercase, isMACAddress, isMobilePhone, isNotEmpty, isNotNull, isNotNullish, isNull, isNullish, isNumber, isObject, isObjectId, isPort, isString, isSWIFT, isTime, isUndefined, isUppercase, isURL, isUUID, isUUID1, isUUID2, isUUID3, isUUID4, isUUID5, isUUID6, isUUID7, isUUID8, toArray, toBigint, toBoolean, toDate, toDateString, toInteger, toNumber, toString, toTime, vg, };
package/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "valgen",
3
3
  "description": "Fast runtime type validator, converter and io (encoding/decoding) library",
4
- "version": "6.0.3",
4
+ "version": "6.1.0",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
7
7
  "dependencies": {
8
8
  "@browsery/validator": "^13.15.35",
9
+ "@jsopen/objects": "^2.2.1",
9
10
  "date-fns": "^4.1.0",
10
11
  "reflect-metadata": "^0.2.2",
11
- "ts-gems": "^3.11.6",
12
+ "ts-gems": "^3.12.0",
12
13
  "tslib": "^2.8.1"
13
14
  },
14
15
  "type": "module",
@@ -1,4 +1,4 @@
1
- import validatorJS from '@browsery/validator';
1
+ import validatorJS, {} from '@browsery/validator';
2
2
  import { validator, } from '../../core/index.js';
3
3
  /**
4
4
  * Validates if value is a "Base64" string.
@@ -1,4 +1,4 @@
1
- import validatorJS from '@browsery/validator';
1
+ import validatorJS, {} from '@browsery/validator';
2
2
  import { validator, } from '../../core/index.js';
3
3
  /**
4
4
  * Validates if value is a credit card number
@@ -1,4 +1,4 @@
1
- import validatorJS from '@browsery/validator';
1
+ import validatorJS, {} from '@browsery/validator';
2
2
  import { validator, } from '../../core/index.js';
3
3
  /**
4
4
  * Validates if value is a valid Email
@@ -1,4 +1,4 @@
1
- import validatorJS from '@browsery/validator';
1
+ import validatorJS, {} from '@browsery/validator';
2
2
  import { validator, } from '../../core/index.js';
3
3
  /**
4
4
  * Validates if value is an FQDN
@@ -1,4 +1,4 @@
1
- import validatorJS from '@browsery/validator';
1
+ import validatorJS, {} from '@browsery/validator';
2
2
  import { validator, } from '../../core/index.js';
3
3
  /**
4
4
  * Validates if value a hash of type algorithm
@@ -1,4 +1,5 @@
1
- import validatorJS from '@browsery/validator';
1
+ import validatorJS, {} from '@browsery/validator';
2
+ import {} from 'ts-gems';
2
3
  import { validator, } from '../../core/index.js';
3
4
  /**
4
5
  * Validates if value is an IP
@@ -1,4 +1,4 @@
1
- import validatorJS from '@browsery/validator';
1
+ import validatorJS, {} from '@browsery/validator';
2
2
  import { validator, } from '../../core/index.js';
3
3
  /**
4
4
  * Validates if value is an ISSN
@@ -1,4 +1,5 @@
1
- import validatorJS from '@browsery/validator';
1
+ import validatorJS, {} from '@browsery/validator';
2
+ import {} from 'ts-gems';
2
3
  import { validator, } from '../../core/index.js';
3
4
  /**
4
5
  * Validates if value is an MACAddress
@@ -1,4 +1,4 @@
1
- import validatorJS from '@browsery/validator';
1
+ import validatorJS, {} from '@browsery/validator';
2
2
  import { validator, } from '../../core/index.js';
3
3
  /**
4
4
  * Validates if value is a valid Email
@@ -1,4 +1,5 @@
1
1
  import validatorJS from '@browsery/validator';
2
+ import {} from 'ts-gems';
2
3
  import { validator, } from '../../core/index.js';
3
4
  /**
4
5
  * Validates if value is a port number
@@ -1,4 +1,4 @@
1
- import validatorJS from '@browsery/validator';
1
+ import validatorJS, {} from '@browsery/validator';
2
2
  import { validator, } from '../../core/index.js';
3
3
  /**
4
4
  * Validates if value is an URL
@@ -1,4 +1,4 @@
1
- import validatorJS from '@browsery/validator';
1
+ import validatorJS, {} from '@browsery/validator';
2
2
  import { validator, } from '../../core/index.js';
3
3
  /**
4
4
  * Validates if value is a "UUID".
@@ -1,4 +1,4 @@
1
- import validatorJS from '@browsery/validator';
1
+ import validatorJS, {} from '@browsery/validator';
2
2
  import { validator, } from '../../core/index.js';
3
3
  /**
4
4
  * Validates if value is a VAT number
package/rules/index.d.ts CHANGED
@@ -44,6 +44,7 @@ export * from './type-rules/is-bigint.js';
44
44
  export * from './type-rules/is-boolean.js';
45
45
  export * from './type-rules/is-date.js';
46
46
  export * from './type-rules/is-enum.js';
47
+ export * from './type-rules/is-instanceof.js';
47
48
  export * from './type-rules/is-integer.js';
48
49
  export * from './type-rules/is-null.js';
49
50
  export * from './type-rules/is-number.js';
package/rules/index.js CHANGED
@@ -44,6 +44,7 @@ export * from './type-rules/is-bigint.js';
44
44
  export * from './type-rules/is-boolean.js';
45
45
  export * from './type-rules/is-date.js';
46
46
  export * from './type-rules/is-enum.js';
47
+ export * from './type-rules/is-instanceof.js';
47
48
  export * from './type-rules/is-integer.js';
48
49
  export * from './type-rules/is-null.js';
49
50
  export * from './type-rules/is-number.js';
@@ -1,4 +1,4 @@
1
- import { type ValidationOptions, type Validator } from '../../core/index.js';
1
+ import type { ValidationOptions, Validator } from '../../core/index.js';
2
2
  /**
3
3
  * Validates if the value is "array" and applies validation for each item.
4
4
  * Converts input value to array if the coerce option is set to 'true'.
@@ -1,4 +1,4 @@
1
- import { validator, } from '../../core/index.js';
1
+ import { validator } from '../../core/index.js';
2
2
  /**
3
3
  * Validates if the value is "array" and applies validation for each item.
4
4
  * Converts input value to array if the coerce option is set to 'true'.
@@ -1,4 +1,5 @@
1
1
  import * as datefns from 'date-fns';
2
+ import {} from 'ts-gems';
2
3
  import { validator, } from '../../core/index.js';
3
4
  /**
4
5
  * Validates if value is a "Date" instance or ISO 8601 formatted date string.
@@ -0,0 +1,11 @@
1
+ import type { Type } from 'ts-gems';
2
+ import { type ValidationOptions } from '../../core/index.js';
3
+ /**
4
+ * Validates if the value instance of given class or classes
5
+ * @validator isUndefined
6
+ */
7
+ export declare function isInstanceOf<T extends object>(clazz: Type<T>, options?: isInstanceOf.Options): import("../../core/validator.js").Validator<T, unknown, import("../../core/types.js").ExecutionOptions>;
8
+ export declare namespace isInstanceOf {
9
+ interface Options extends ValidationOptions {
10
+ }
11
+ }
@@ -0,0 +1,17 @@
1
+ import { isPlainObject } from '@jsopen/objects';
2
+ import { validator, } from '../../core/index.js';
3
+ /**
4
+ * Validates if the value instance of given class or classes
5
+ * @validator isUndefined
6
+ */
7
+ export function isInstanceOf(clazz, options) {
8
+ return validator('isInstanceOf', (input, context, _this) => {
9
+ if ((options?.coerce ?? context.coerce) && isPlainObject(input)) {
10
+ Object.setPrototypeOf(input, clazz.prototype);
11
+ }
12
+ if (!(input instanceof clazz)) {
13
+ context.fail(_this, `Value must be an instance of "${clazz.name}"`, input);
14
+ }
15
+ return input;
16
+ }, options);
17
+ }
@@ -1,4 +1,4 @@
1
- import { type ValidationOptions, type Validator } from '../../core/index.js';
1
+ import type { ValidationOptions, Validator } from '../../core/index.js';
2
2
  /**
3
3
  * Validates the record object according to given "key" and "value" rules
4
4
  * Converts properties according to rules if the coerce option is set to 'true'.
@@ -1,4 +1,4 @@
1
- import { validator, } from '../../core/index.js';
1
+ import { validator } from '../../core/index.js';
2
2
  /**
3
3
  * Validates the record object according to given "key" and "value" rules
4
4
  * Converts properties according to rules if the coerce option is set to 'true'.
@@ -1,4 +1,4 @@
1
- import { ValidationOptions, type Validator } from '../../core/index.js';
1
+ import type { ValidationOptions, Validator } from '../../core/index.js';
2
2
  /**
3
3
  * Test given value against to all codecs and returns original input
4
4
  * @validator allOf
@@ -1,4 +1,4 @@
1
- import { validator, } from '../../core/index.js';
1
+ import { validator } from '../../core/index.js';
2
2
  /**
3
3
  * Test given value against to all codecs and returns original input
4
4
  * @validator allOf
@@ -1,4 +1,4 @@
1
- import { ValidationOptions, type Validator } from '../../core/index.js';
1
+ import type { ValidationOptions, Validator } from '../../core/index.js';
2
2
  type DiscriminatorRecord = Record<string, Validator>;
3
3
  /**
4
4
  *
@@ -1,4 +1,4 @@
1
- import { validator, } from '../../core/index.js';
1
+ import { validator } from '../../core/index.js';
2
2
  /**
3
3
  *
4
4
  */