@tldraw/tlvalidate
Advanced tools
Comparing version 0.1.0-alpha.6 to 0.1.0-alpha.7
@@ -34,4 +34,6 @@ "use strict"; | ||
dict: () => dict, | ||
integer: () => integer, | ||
literal: () => literal, | ||
model: () => model, | ||
nonZeroInteger: () => nonZeroInteger, | ||
nonZeroNumber: () => nonZeroNumber, | ||
@@ -41,2 +43,3 @@ number: () => number, | ||
point: () => point, | ||
positiveInteger: () => positiveInteger, | ||
positiveNumber: () => positiveNumber, | ||
@@ -210,2 +213,5 @@ setEnum: () => setEnum, | ||
} | ||
allowUnknownProperties() { | ||
return new ObjectValidator(this.config, true); | ||
} | ||
extend(extension) { | ||
@@ -286,2 +292,14 @@ return new ObjectValidator({ ...this.config, ...extension }); | ||
}); | ||
const integer = number.check((value) => { | ||
if (!Number.isInteger(value)) | ||
throw new ValidationError(`Expected an integer, got ${value}`); | ||
}); | ||
const positiveInteger = integer.check((value) => { | ||
if (value < 0) | ||
throw new ValidationError(`Expected a positive integer, got ${value}`); | ||
}); | ||
const nonZeroInteger = integer.check((value) => { | ||
if (value <= 0) | ||
throw new ValidationError(`Expected a non-zero positive integer, got ${value}`); | ||
}); | ||
const boolean = typeofValidator("boolean"); | ||
@@ -288,0 +306,0 @@ const bigint = typeofValidator("bigint"); |
@@ -161,2 +161,5 @@ import { exhaustiveSwitchError, getOwnProperty, hasOwnProperty } from "@tldraw/utils"; | ||
} | ||
allowUnknownProperties() { | ||
return new ObjectValidator(this.config, true); | ||
} | ||
extend(extension) { | ||
@@ -237,2 +240,14 @@ return new ObjectValidator({ ...this.config, ...extension }); | ||
}); | ||
const integer = number.check((value) => { | ||
if (!Number.isInteger(value)) | ||
throw new ValidationError(`Expected an integer, got ${value}`); | ||
}); | ||
const positiveInteger = integer.check((value) => { | ||
if (value < 0) | ||
throw new ValidationError(`Expected a positive integer, got ${value}`); | ||
}); | ||
const nonZeroInteger = integer.check((value) => { | ||
if (value <= 0) | ||
throw new ValidationError(`Expected a non-zero positive integer, got ${value}`); | ||
}); | ||
const boolean = typeofValidator("boolean"); | ||
@@ -317,4 +332,6 @@ const bigint = typeofValidator("bigint"); | ||
dict, | ||
integer, | ||
literal, | ||
model, | ||
nonZeroInteger, | ||
nonZeroNumber, | ||
@@ -324,2 +341,3 @@ number, | ||
point, | ||
positiveInteger, | ||
positiveNumber, | ||
@@ -326,0 +344,0 @@ setEnum, |
@@ -63,2 +63,8 @@ /** | ||
/** | ||
* Fails if number is not an integer | ||
* @public | ||
*/ | ||
declare const integer: Validator<number>; | ||
/** | ||
* Validates that a value matches another that was passed in. | ||
@@ -86,2 +92,8 @@ * | ||
/** | ||
* Fails if value \<= 0 and is not an integer | ||
* @public | ||
*/ | ||
declare const nonZeroInteger: Validator<number>; | ||
/** | ||
* Fails if value \<= 0 | ||
@@ -115,2 +127,3 @@ * @public | ||
}, shouldAllowUnknownProperties?: boolean); | ||
allowUnknownProperties(): ObjectValidator<Shape>; | ||
/** | ||
@@ -142,2 +155,8 @@ * Extend an object validator by adding additional properties. | ||
/** | ||
* Fails if value \< 0 and is not an integer | ||
* @public | ||
*/ | ||
declare const positiveInteger: Validator<number>; | ||
/** | ||
* Fails if value \< 0 | ||
@@ -180,2 +199,5 @@ * @public | ||
nonZeroNumber, | ||
integer, | ||
positiveInteger, | ||
nonZeroInteger, | ||
boolean, | ||
@@ -182,0 +204,0 @@ bigint, |
@@ -5,3 +5,3 @@ { | ||
"description": "A tiny little drawing app (validation).", | ||
"version": "0.1.0-alpha.6", | ||
"version": "0.1.0-alpha.7", | ||
"author": "tldraw GB Ltd.", | ||
@@ -31,3 +31,3 @@ "homepage": "https://tldraw.dev", | ||
"dependencies": { | ||
"@tldraw/utils": "0.1.0-alpha.6" | ||
"@tldraw/utils": "0.1.0-alpha.7" | ||
}, | ||
@@ -34,0 +34,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
79822
1042
+ Added@tldraw/utils@0.1.0-alpha.7(transitive)
- Removed@tldraw/utils@0.1.0-alpha.6(transitive)
Updated@tldraw/utils@0.1.0-alpha.7