Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tldraw/tlvalidate

Package Overview
Dependencies
Maintainers
4
Versions
319
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tldraw/tlvalidate - npm Package Compare versions

Comparing version 2.0.0-canary.03e6951d3 to 2.0.0-canary.042edeb4b445

README.md

24

CHANGELOG.md

@@ -0,1 +1,25 @@

# v2.0.0-alpha.12 (Mon Apr 03 2023)
#### 🐛 Bug Fix
- Make sure all types and build stuff get run in CI [#1548](https://github.com/tldraw/tldraw-lite/pull/1548) ([@SomeHats](https://github.com/SomeHats))
- add pre-commit api report generation [#1517](https://github.com/tldraw/tldraw-lite/pull/1517) ([@SomeHats](https://github.com/SomeHats))
- [chore] restore api extractor [#1500](https://github.com/tldraw/tldraw-lite/pull/1500) ([@steveruizok](https://github.com/steveruizok))
- David/publish good [#1488](https://github.com/tldraw/tldraw-lite/pull/1488) ([@ds300](https://github.com/ds300))
- [chore] alpha 10 [#1486](https://github.com/tldraw/tldraw-lite/pull/1486) ([@ds300](https://github.com/ds300))
- [chore] bump for alpha 8 [#1485](https://github.com/tldraw/tldraw-lite/pull/1485) ([@steveruizok](https://github.com/steveruizok))
- [improvement] API Reference docs [#1478](https://github.com/tldraw/tldraw-lite/pull/1478) ([@steveruizok](https://github.com/steveruizok))
- stop using broken-af turbo for publishing [#1476](https://github.com/tldraw/tldraw-lite/pull/1476) ([@ds300](https://github.com/ds300))
- [chore] add canary release script [#1423](https://github.com/tldraw/tldraw-lite/pull/1423) ([@ds300](https://github.com/ds300) [@steveruizok](https://github.com/steveruizok))
- [chore] upgrade yarn [#1430](https://github.com/tldraw/tldraw-lite/pull/1430) ([@ds300](https://github.com/ds300))
- repo cleanup [#1426](https://github.com/tldraw/tldraw-lite/pull/1426) ([@steveruizok](https://github.com/steveruizok))
#### Authors: 3
- alex ([@SomeHats](https://github.com/SomeHats))
- David Sheldrick ([@ds300](https://github.com/ds300))
- Steve Ruiz ([@steveruizok](https://github.com/steveruizok))
---
# @tldraw/tlvalidate

@@ -2,0 +26,0 @@

81

dist-cjs/index.d.ts
/**
* Validation that accepts any value. Generally this should be avoided, but you
* can use it as an escape hatch if you want to work without validations for
* e.g. a prototype.
* Validation that accepts any value. Generally this should be avoided, but you can use it as an
* escape hatch if you want to work without validations for e.g. a prototype.
*
* @public

@@ -11,2 +11,3 @@ */

* Validates that a value is an array. To check the contents of the array, use T.arrayOf.
*
* @public

@@ -18,2 +19,3 @@ */

* Validates that a value is an array whose contents matches the passed-in validator.
*
* @public

@@ -33,2 +35,3 @@ */

* Validates that a value is a bigint.
*
* @public

@@ -40,2 +43,3 @@ */

* Validates that a value is boolean.
*
* @public

@@ -55,2 +59,3 @@ */

* Validation that an option is a dict with particular keys and values.
*
* @public

@@ -69,2 +74,3 @@ */

* Fails if number is not an integer
*
* @public

@@ -78,2 +84,3 @@ */

* @example
*
* ```ts

@@ -85,7 +92,7 @@ * const trueValidator = T.literal(true)

*/
declare function literal<T extends string | number | boolean>(expectedValue: T): Validator<T>;
declare function literal<T extends boolean | number | string>(expectedValue: T): Validator<T>;
/**
* A named object with an ID. Errors will be reported as being part of the
* object with the given name.
* A named object with an ID. Errors will be reported as being part of the object with the given
* name.
*

@@ -100,2 +107,3 @@ * @public

* Fails if value \<= 0 and is not an integer
*
* @public

@@ -107,2 +115,3 @@ */

* Fails if value \<= 0
*
* @public

@@ -114,2 +123,3 @@ */

* Validates that a value is a finite non-NaN number.
*
* @public

@@ -121,2 +131,3 @@ */

* Validate an object has a particular shape.
*
* @public

@@ -142,9 +153,10 @@ */

* @example
*
* ```ts
* const animalValidator = T.object({
* name: T.string,
* })
* const catValidator = animalValidator.extend({
* meowVolume: T.number,
* })
* const animalValidator = T.object({
* name: T.string,
* })
* const catValidator = animalValidator.extend({
* meowVolume: T.number,
* })
* ```

@@ -166,2 +178,3 @@ */

* Fails if value \< 0 and is not an integer
*
* @public

@@ -173,2 +186,3 @@ */

* Fails if value \< 0
*
* @public

@@ -183,2 +197,3 @@ */

* Validates that a value is a string.
*
* @public

@@ -228,10 +243,11 @@ */

/**
* Validate a union of several object types. Each object must have a property
* matching `key` which should be a unique string.
* Validate a union of several object types. Each object must have a property matching `key` which
* should be a unique string.
*
* @example
*
* ```ts
* const catValidator = T.object({ kind: T.value('cat'), meow: T.boolean })
* const dogValidator = T.object({ kind: T.value('dog'), bark: T.boolean })
* const animalValidator = T.union('kind', {cat: catValidator, dog: dogValidator})
* const animalValidator = T.union('kind', { cat: catValidator, dog: dogValidator })
* ```

@@ -261,3 +277,5 @@ *

/**
* Validation that accepts any value. Useful as a starting point for building your own custom validations.
* Validation that accepts any value. Useful as a starting point for building your own custom
* validations.
*
* @public

@@ -283,21 +301,19 @@ */

/**
* Asserts that the passed value is of the correct type and returns it. The
* returned value is guaranteed to be referentially equal to the passed
* value.
* Asserts that the passed value is of the correct type and returns it. The returned value is
* guaranteed to be referentially equal to the passed value.
*/
validate(value: unknown): T;
/**
* Returns a new validator that also accepts null or undefined. The
* resulting value will always be null.
* Returns a new validator that also accepts null or undefined. The resulting value will always be
* null.
*/
nullable(): Validator<T | null>;
nullable(): Validator<null | T>;
/**
* Returns a new validator that also accepts null or undefined. The
* resulting value will always be null.
* Returns a new validator that also accepts null or undefined. The resulting value will always be
* null.
*/
optional(): Validator<T | undefined>;
/**
* Refine this validation to a new type. The passed-in validation function
* should throw an error if the value can't be converted to the new type, or
* return the new type otherwise.
* Refine this validation to a new type. The passed-in validation function should throw an error
* if the value can't be converted to the new type, or return the new type otherwise.
*/

@@ -309,8 +325,9 @@ refine<U>(otherValidationFn: (value: T) => U): Validator<U>;

* @example
*
* ```ts
* const numberLessThan10Validator = T.number.check((value) => {
* if (value >= 10) {
* throw new ValidationError(`Expected number less than 10, got ${value}`)
* }
* })
* const numberLessThan10Validator = T.number.check((value) => {
* if (value >= 10) {
* throw new ValidationError(`Expected number less than 10, got ${value}`)
* }
* })
* ```

@@ -317,0 +334,0 @@ */

"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {

@@ -14,7 +20,17 @@ if (from && typeof from === "object" || typeof from === "function") {

};
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var src_exports = {};
__export(src_exports, {
T: () => T
});
module.exports = __toCommonJS(src_exports);
__reExport(src_exports, require("./lib"), module.exports);
var T = __toESM(require("./lib/validation"));
//# sourceMappingURL=index.js.map

@@ -122,5 +122,4 @@ "use strict";

/**
* Asserts that the passed value is of the correct type and returns it. The
* returned value is guaranteed to be referentially equal to the passed
* value.
* Asserts that the passed value is of the correct type and returns it. The returned value is
* guaranteed to be referentially equal to the passed value.
*/

@@ -135,4 +134,4 @@ validate(value) {

/**
* Returns a new validator that also accepts null or undefined. The
* resulting value will always be null.
* Returns a new validator that also accepts null or undefined. The resulting value will always be
* null.
*/

@@ -147,4 +146,4 @@ nullable() {

/**
* Returns a new validator that also accepts null or undefined. The
* resulting value will always be null.
* Returns a new validator that also accepts null or undefined. The resulting value will always be
* null.
*/

@@ -159,5 +158,4 @@ optional() {

/**
* Refine this validation to a new type. The passed-in validation function
* should throw an error if the value can't be converted to the new type, or
* return the new type otherwise.
* Refine this validation to a new type. The passed-in validation function should throw an error
* if the value can't be converted to the new type, or return the new type otherwise.
*/

@@ -240,9 +238,10 @@ refine(otherValidationFn) {

* @example
*
* ```ts
* const animalValidator = T.object({
* name: T.string,
* })
* const catValidator = animalValidator.extend({
* meowVolume: T.number,
* })
* const animalValidator = T.object({
* name: T.string,
* })
* const catValidator = animalValidator.extend({
* meowVolume: T.number,
* })
* ```

@@ -249,0 +248,0 @@ */

{
"name": "@tldraw/tlvalidate",
"description": "A tiny little drawing app (validation).",
"version": "2.0.0-canary.03e6951d3",
"version": "2.0.0-canary.042edeb4b445",
"packageManager": "yarn@3.5.0",
"author": {

@@ -34,14 +35,13 @@ "name": "tldraw GB Ltd.",

"scripts": {
"test": "yarn run -T jest",
"test:coverage": "yarn run -T jest --coverage",
"build:types": "yarn run -T tsx ../../scripts/build-types.ts",
"build": "echo 'build should be run by turbo'",
"build:package": "yarn run -T tsx ../../scripts/build-package.ts",
"build:api": "yarn run -T tsx ../../scripts/build-api.ts",
"test": "lazy inherit",
"test-coverage": "lazy inherit",
"build": "yarn run -T tsx ../../scripts/build-package.ts",
"build-api": "yarn run -T tsx ../../scripts/build-api.ts",
"prepack": "yarn run -T tsx ../../scripts/prepack.ts",
"postpack": "../../scripts/postpack.sh",
"pack-tarball": "yarn pack",
"lint": "yarn run -T tsx ../../scripts/lint.ts"
},
"dependencies": {
"@tldraw/utils": "2.0.0-canary.03e6951d3"
"@tldraw/utils": "2.0.0-canary.042edeb4b445"
},

@@ -57,2 +57,5 @@ "jest": {

},
"devDependencies": {
"lazyrepo": "0.0.0-alpha.26"
},
"module": "dist-esm/index.mjs",

@@ -59,0 +62,0 @@ "source": "src/index.ts",

@@ -1,1 +0,3 @@

export * from './lib'
import * as T from './lib/validation'
export { T }

@@ -87,5 +87,4 @@ import { exhaustiveSwitchError, getOwnProperty, hasOwnProperty } from '@tldraw/utils'

/**
* Asserts that the passed value is of the correct type and returns it. The
* returned value is guaranteed to be referentially equal to the passed
* value.
* Asserts that the passed value is of the correct type and returns it. The returned value is
* guaranteed to be referentially equal to the passed value.
*/

@@ -101,4 +100,4 @@ validate(value: unknown): T {

/**
* Returns a new validator that also accepts null or undefined. The
* resulting value will always be null.
* Returns a new validator that also accepts null or undefined. The resulting value will always be
* null.
*/

@@ -113,4 +112,4 @@ nullable(): Validator<T | null> {

/**
* Returns a new validator that also accepts null or undefined. The
* resulting value will always be null.
* Returns a new validator that also accepts null or undefined. The resulting value will always be
* null.
*/

@@ -125,5 +124,4 @@ optional(): Validator<T | undefined> {

/**
* Refine this validation to a new type. The passed-in validation function
* should throw an error if the value can't be converted to the new type, or
* return the new type otherwise.
* Refine this validation to a new type. The passed-in validation function should throw an error
* if the value can't be converted to the new type, or return the new type otherwise.
*/

@@ -140,8 +138,9 @@ refine<U>(otherValidationFn: (value: T) => U): Validator<U> {

* @example
*
* ```ts
* const numberLessThan10Validator = T.number.check((value) => {
* if (value >= 10) {
* throw new ValidationError(`Expected number less than 10, got ${value}`)
* }
* })
* const numberLessThan10Validator = T.number.check((value) => {
* if (value >= 10) {
* throw new ValidationError(`Expected number less than 10, got ${value}`)
* }
* })
* ```

@@ -234,9 +233,10 @@ */

* @example
*
* ```ts
* const animalValidator = T.object({
* name: T.string,
* })
* const catValidator = animalValidator.extend({
* meowVolume: T.number,
* })
* const animalValidator = T.object({
* name: T.string,
* })
* const catValidator = animalValidator.extend({
* meowVolume: T.number,
* })
* ```

@@ -331,3 +331,5 @@ */

/**
* Validation that accepts any value. Useful as a starting point for building your own custom validations.
* Validation that accepts any value. Useful as a starting point for building your own custom
* validations.
*
* @public

@@ -337,5 +339,5 @@ */

/**
* Validation that accepts any value. Generally this should be avoided, but you
* can use it as an escape hatch if you want to work without validations for
* e.g. a prototype.
* Validation that accepts any value. Generally this should be avoided, but you can use it as an
* escape hatch if you want to work without validations for e.g. a prototype.
*
* @public

@@ -347,2 +349,3 @@ */

* Validates that a value is a string.
*
* @public

@@ -354,2 +357,3 @@ */

* Validates that a value is a finite non-NaN number.
*
* @public

@@ -367,2 +371,3 @@ */

* Fails if value \< 0
*
* @public

@@ -375,2 +380,3 @@ */

* Fails if value \<= 0
*
* @public

@@ -383,2 +389,3 @@ */

* Fails if number is not an integer
*
* @public

@@ -391,2 +398,3 @@ */

* Fails if value \< 0 and is not an integer
*
* @public

@@ -399,2 +407,3 @@ */

* Fails if value \<= 0 and is not an integer
*
* @public

@@ -408,2 +417,3 @@ */

* Validates that a value is boolean.
*
* @public

@@ -414,2 +424,3 @@ */

* Validates that a value is a bigint.
*
* @public

@@ -422,2 +433,3 @@ */

* @example
*
* ```ts

@@ -440,2 +452,3 @@ * const trueValidator = T.literal(true)

* Validates that a value is an array. To check the contents of the array, use T.arrayOf.
*
* @public

@@ -452,2 +465,3 @@ */

* Validates that a value is an array whose contents matches the passed-in validator.
*
* @public

@@ -469,2 +483,3 @@ */

* Validate an object has a particular shape.
*
* @public

@@ -480,2 +495,3 @@ */

* Validation that an option is a dict with particular keys and values.
*
* @public

@@ -491,10 +507,11 @@ */

/**
* Validate a union of several object types. Each object must have a property
* matching `key` which should be a unique string.
* Validate a union of several object types. Each object must have a property matching `key` which
* should be a unique string.
*
* @example
*
* ```ts
* const catValidator = T.object({ kind: T.value('cat'), meow: T.boolean })
* const dogValidator = T.object({ kind: T.value('dog'), bark: T.boolean })
* const animalValidator = T.union('kind', {cat: catValidator, dog: dogValidator})
* const animalValidator = T.union('kind', { cat: catValidator, dog: dogValidator })
* ```

@@ -519,4 +536,4 @@ *

/**
* A named object with an ID. Errors will be reported as being part of the
* object with the given name.
* A named object with an ID. Errors will be reported as being part of the object with the given
* name.
*

@@ -523,0 +540,0 @@ * @public

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

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