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

typanion

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typanion - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

10

lib/index.d.ts

@@ -5,4 +5,4 @@ type Trait<Type> = {

type InferType<U> = U extends Trait<infer V> ? V : never;
type LooseTest<U> = (value: U, errors?: string[], p?: string) => boolean;
type StrictTest<U, V extends U> = (value: U, errors?: string[], p?: string) => value is V;
type LooseTest<U> = (value: U, errors?: string[] | null, p?: string) => boolean;
type StrictTest<U, V extends U> = (value: U, errors?: string[] | null, p?: string) => value is V;
type LooseValidator<U, V> = LooseTest<U> & Trait<V>;

@@ -27,3 +27,3 @@ type StrictValidator<U, V extends U> = StrictTest<U, V> & Trait<V>;

declare const isBoolean: () => StrictValidator<unknown, boolean>;
declare const isNumber: () => StrictValidator<unknown, boolean>;
declare const isNumber: () => StrictValidator<unknown, number>;
declare const isArray: <T extends StrictValidator<any, any>>(spec: T) => StrictValidator<unknown, InferType<T>[]>;

@@ -48,2 +48,4 @@ declare const isObject: <T extends { [P in keyof T]: StrictValidator<any, any>; }>(props: T, { allowUnknownKeys, }?: {

}>(length: number) => LooseValidator<T, T>;
declare const isNegative: () => LooseValidator<number, number>;
declare const isPositive: () => LooseValidator<number, number>;
declare const isAtLeast: (n: number) => LooseValidator<number, number>;

@@ -58,2 +60,2 @@ declare const isAtMost: (n: number) => LooseValidator<number, number>;

declare const isUUID4: () => LooseValidator<string, string>;
export { Trait, InferType, LooseTest, StrictTest, LooseValidator, StrictValidator, AnyStrictValidator, simpleKeyRegExp, uuid4RegExp, makeTrait, makeValidator, getPrintable, addKey, pushError, isUnknown, isLiteral, isString, isBoolean, isNumber, isArray, isObject, isOneOf, applyCascade, isOptional, isNullable, hasMinLength, hasMaxLength, hasExactLength, isAtLeast, isAtMost, isInInclusiveRange, isInExclusiveRange, isInteger, matchesRegExp, isLowerCase, isUpperCase, isUUID4 };
export { Trait, InferType, LooseTest, StrictTest, LooseValidator, StrictValidator, AnyStrictValidator, simpleKeyRegExp, uuid4RegExp, makeTrait, makeValidator, getPrintable, addKey, pushError, isUnknown, isLiteral, isString, isBoolean, isNumber, isArray, isObject, isOneOf, applyCascade, isOptional, isNullable, hasMinLength, hasMaxLength, hasExactLength, isNegative, isPositive, isAtLeast, isAtMost, isInInclusiveRange, isInExclusiveRange, isInteger, matchesRegExp, isLowerCase, isUpperCase, isUUID4 };

@@ -183,2 +183,18 @@ 'use strict';

});
const isNegative = () => makeValidator({
test: (value, errors, p) => {
const res = value <= 0;
if (!res)
pushError(errors, p, `Expected to be negative (got ${value})`);
return res;
},
});
const isPositive = () => makeValidator({
test: (value, errors, p) => {
const res = value >= 0;
if (!res)
pushError(errors, p, `Expected to be positive (got ${value})`);
return res;
},
});
const isAtLeast = (n) => makeValidator({

@@ -272,2 +288,3 @@ test: (value, errors, p) => {

exports.isLowerCase = isLowerCase;
exports.isNegative = isNegative;
exports.isNullable = isNullable;

@@ -278,2 +295,3 @@ exports.isNumber = isNumber;

exports.isOptional = isOptional;
exports.isPositive = isPositive;
exports.isString = isString;

@@ -280,0 +298,0 @@ exports.isUUID4 = isUUID4;

3

package.json
{
"name": "typanion",
"version": "2.0.0",
"version": "2.0.1",
"main": "lib/index",
"license": "MIT",
"sideEffects": false,
"repository": {

@@ -7,0 +8,0 @@ "url": "https://github.com/arcanis/typanion",

@@ -20,3 +20,3 @@ # Typanion

Compared to [yup](https://github.com/jquense/yup), Typanion has a better inference support for TypeScript + supports `isOneOf`. It's functional API makes it very easy to tree shake, which is another bonus (although the library isn't very large in itself).
Compared to [yup](https://github.com/jquense/yup), Typanion has a better inference support for TypeScript + supports `isOneOf`. Its functional API makes it very easy to tree shake, which is another bonus (although the library isn't very large in itself).

@@ -139,2 +139,6 @@ ## Usage

- `isNegative` will ensure that the values are at most 0.
- `isPositive` will ensure that the values are at least 0.
- `isUpperCase` will ensure that the values only contain uppercase characters.

@@ -141,0 +145,0 @@

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