Socket
Socket
Sign inDemoInstall

schema-typed

Package Overview
Dependencies
0
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.0 to 2.0.1

4

CHANGELOG.md

@@ -0,1 +1,5 @@

# 2.0.1
- fix ArrayType.of type error #35
# 2.0.0

@@ -2,0 +6,0 @@

4

es/ArrayType.d.ts
import { MixedType } from './MixedType';
import { CheckType, ErrorMessageType } from './types';
import { ErrorMessageType } from './types';
import { ArrayTypeLocale } from './locales';

@@ -10,4 +10,4 @@ export declare class ArrayType<DataType = any, E = ErrorMessageType> extends MixedType<any[], DataType, E, ArrayTypeLocale> {

unrepeatable(errorMessage?: E | string): this;
of(type: CheckType<any[], DataType, E>): this;
of(type: MixedType<any, DataType, E>): this;
}
export default function getArrayType<DataType = any, E = string>(errorMessage?: E): ArrayType<DataType, E>;
import { MixedType } from './MixedType';
import { CheckType, ErrorMessageType } from './types';
import { ErrorMessageType } from './types';
import { ArrayTypeLocale } from './locales';

@@ -10,4 +10,4 @@ export declare class ArrayType<DataType = any, E = ErrorMessageType> extends MixedType<any[], DataType, E, ArrayTypeLocale> {

unrepeatable(errorMessage?: E | string): this;
of(type: CheckType<any[], DataType, E>): this;
of(type: MixedType<any, DataType, E>): this;
}
export default function getArrayType<DataType = any, E = string>(errorMessage?: E): ArrayType<DataType, E>;
{
"name": "schema-typed",
"version": "2.0.0",
"version": "2.0.1",
"description": "Schema for data modeling & validation",

@@ -58,4 +58,4 @@ "main": "lib/index.js",

"@babel/runtime-corejs2": "^7.8.4",
"@typescript-eslint/eslint-plugin": "^4.16.1",
"@typescript-eslint/parser": "^4.16.1",
"@typescript-eslint/eslint-plugin": "^4.29.3",
"@typescript-eslint/parser": "^4.29.3",
"babel-eslint": "^9.0.0",

@@ -62,0 +62,0 @@ "chai": "^3.5.0",

@@ -81,2 +81,12 @@ import {

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// PASSING SCENARIO 7: Should allow other types to be included in ArrayType
ArrayType().of(NumberType());
ArrayType().of(ObjectType());
ArrayType().of(ArrayType());
ArrayType().of(BooleanType());
ArrayType().of(StringType());
ArrayType().of(DateType());
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// FAIL SCENARIO 1: Should fail if type check is not matching declared type

@@ -198,9 +208,17 @@

// $ExpectError
schemaF8.checkForField('c', 'a');
schemaF8.checkForField('c', { a: 'str' });
// TS2345: Argument of type '"c"' is not assignable to parameter of type '"a"'.
// $ExpectError
schemaF8.checkForFieldAsync('c', 'a');
schemaF8.checkForFieldAsync('c', { a: 'str' });
// TS2345: Argument of type '"c"' is not assignable to parameter of type '"a"'.
// $ExpectError
schemaF8.checkForField('a', { c: 'str' });
// TS2345: Argument of type '{ c: string; }' is not assignable to parameter of type '{ a: unknown; }'.
// $ExpectError
schemaF8.checkForFieldAsync('a', { c: 'str' });
// TS2345: Argument of type '{ c: string; }' is not assignable to parameter of type '{ a: unknown; }'.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

@@ -224,12 +242,1 @@ // FAIL SCENARIO 9: Should fail if ObjectType will get not matched shape

});
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// FAIL SCENARIO 10: Should fail if ArrayType will get not matched shape
interface F10 {
a: string;
}
// $ExpectError
ArrayType<F10>().of(StringType());
// TS2345: Argument of type 'StringType<any>' is not assignable to parameter of type 'ObjectType<F10, any>'.
// Property 'shape' is missing in type 'StringType<any>' but required in type 'ObjectType<F10, any>'.
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc