Comparing version 0.6.1 to 0.6.2
@@ -15,2 +15,7 @@ # Changelog | ||
# 0.6.2 | ||
- **New Feature** | ||
- add aliases for `null` and `interface`, closes #63 (@gcanti) | ||
# 0.6.1 | ||
@@ -17,0 +22,0 @@ |
@@ -44,3 +44,4 @@ import { Either } from 'fp-ts/lib/Either'; | ||
} | ||
declare const nullType: NullType; | ||
/** An alias of `null` */ | ||
export declare const nullType: NullType; | ||
export interface UndefinedType extends Type<undefined> { | ||
@@ -128,3 +129,4 @@ readonly _tag: 'UndefinedType'; | ||
} | ||
export declare function _interface<P extends Props>(props: P, name?: string): InterfaceType<P>; | ||
/** An alias of `interface` */ | ||
export declare function type<P extends Props>(props: P, name?: string): InterfaceType<P>; | ||
export declare type PartialOf<P extends Props> = { | ||
@@ -182,2 +184,2 @@ [K in keyof P]?: TypeOf<P[K]>; | ||
export declare function readonlyArray<RT extends Any>(type: RT, name?: string): ReadonlyArrayType<RT>; | ||
export { nullType as null, undefinedType as undefined, arrayType as Array, functionType as Function, _interface as interface }; | ||
export { nullType as null, undefinedType as undefined, arrayType as Array, functionType as Function, type as interface }; |
@@ -60,3 +60,4 @@ "use strict"; | ||
exports.mapWithName = mapWithName; | ||
var nullType = { | ||
/** An alias of `null` */ | ||
exports.nullType = { | ||
_A: exports._A, | ||
@@ -67,3 +68,3 @@ _tag: 'NullType', | ||
}; | ||
exports.null = nullType; | ||
exports.null = exports.nullType; | ||
var undefinedType = { | ||
@@ -207,3 +208,4 @@ _A: exports._A, | ||
exports.array = array; | ||
function _interface(props, name) { | ||
/** An alias of `interface` */ | ||
function type(props, name) { | ||
return { | ||
@@ -220,4 +222,4 @@ _A: exports._A, | ||
var ok = o[k]; | ||
var type = props[k]; | ||
var validation = type.validate(ok, c.concat(getContextEntry(k, type))); | ||
var type_1 = props[k]; | ||
var validation = type_1.validate(ok, c.concat(getContextEntry(k, type_1))); | ||
validation.fold(function (error) { return pushAll(errors, error); }, function (vok) { | ||
@@ -237,4 +239,4 @@ changed = changed || vok !== ok; | ||
} | ||
exports._interface = _interface; | ||
exports.interface = _interface; | ||
exports.type = type; | ||
exports.interface = type; | ||
function partial(props, name) { | ||
@@ -245,8 +247,8 @@ var partials = {}; | ||
} | ||
var type = _interface(partials); | ||
var partial = type(partials); | ||
return { | ||
_A: exports._A, | ||
_tag: 'PartialType', | ||
name: name || type.name, | ||
validate: function (v, c) { return type.validate(v, c); }, | ||
name: name || partial.name, | ||
validate: function (v, c) { return partial.validate(v, c); }, | ||
props: partials | ||
@@ -318,4 +320,4 @@ }; | ||
for (var i = 0; i < types.length; i++) { | ||
var type = types[i]; | ||
var validation = type.validate(t, c); | ||
var type_2 = types[i]; | ||
var validation = type_2.validate(t, c); | ||
validation.fold(function (error) { return pushAll(errors, error); }, function (vv) { | ||
@@ -344,4 +346,4 @@ changed = changed || vv !== t; | ||
var a = as[i]; | ||
var type = types[i]; | ||
var validation = type.validate(a, c.concat(getContextEntry(String(i), type))); | ||
var type_3 = types[i]; | ||
var validation = type_3.validate(a, c.concat(getContextEntry(String(i), type_3))); | ||
validation.fold(function (error) { return pushAll(errors, error); }, function (va) { | ||
@@ -348,0 +350,0 @@ changed = changed || va !== a; |
{ | ||
"name": "io-ts", | ||
"version": "0.6.1", | ||
"version": "0.6.2", | ||
"description": "TypeScript compatible runtime type system for IO validation", | ||
@@ -5,0 +5,0 @@ "files": ["lib"], |
@@ -137,3 +137,3 @@ # The idea | ||
|------|-------|-------------| | ||
| null | `null` | `t.null` | | ||
| null | `null` | `t.null` or `t.nullType` | | ||
| undefined | `undefined` | `t.undefined` | | ||
@@ -155,3 +155,3 @@ | string | `string` | `t.string` | | ||
| readonly array | `ReadonlyArray<number>` | `t.readonlyArray(t.number)` | | ||
| interface | `interface A { name: string }` | `t.interface({ name: t.string })` | | ||
| interface | `interface A { name: string }` | `t.interface({ name: t.string })` or `t.type({ name: t.string })` | | ||
| interface inheritance | `interface B extends A {}` | `t.intersection([ A, t.interface({}) ])` | | ||
@@ -158,0 +158,0 @@ | tuple | `[ A, B ]` | `t.tuple([ A, B ])` | |
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
52715
622