Comparing version 1.1.2 to 1.1.3
@@ -16,2 +16,7 @@ # Changelog | ||
# 1.1.3 | ||
* **Internal** | ||
* upgrade to `typings-checker@2.0.0` (@gcanti) | ||
# 1.1.2 | ||
@@ -18,0 +23,0 @@ |
@@ -892,4 +892,2 @@ "use strict"; | ||
exports.ExactType = ExactType; | ||
// typings-checker doesn't know Object.assign | ||
var assign = Object.assign; | ||
var getProps = function (type) { | ||
@@ -905,3 +903,3 @@ switch (type._tag) { | ||
case 'IntersectionType': | ||
return type.types.reduce(function (props, type) { return assign(props, getProps(type)); }, {}); | ||
return type.types.reduce(function (props, type) { return Object.assign(props, getProps(type)); }, {}); | ||
} | ||
@@ -908,0 +906,0 @@ }; |
{ | ||
"name": "io-ts", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "TypeScript compatible runtime type system for IO validation", | ||
@@ -47,3 +47,3 @@ "files": ["lib"], | ||
"typescript": "2.8.3", | ||
"typings-checker": "1.1.2" | ||
"typings-checker": "2.0.0" | ||
}, | ||
@@ -50,0 +50,0 @@ "tags": ["typescript", "validation", "inference", "types", "runtime"], |
@@ -324,19 +324,32 @@ [![build status](https://img.shields.io/travis/gcanti/io-ts/master.svg?style=flat-square)](https://travis-ci.org/gcanti/io-ts) | ||
No, however you can define your own logic for that (if you _really_ trust the input and the involved types don't perform | ||
deserializations) | ||
No, however you can define your own logic for that (if you _really_ trust the input) | ||
```ts | ||
import * as t from 'io-ts' | ||
import { failure } from 'io-ts/lib/PathReporter' | ||
import { Either, right } from 'fp-ts/lib/Either' | ||
const { NODE_ENV } = process.env | ||
export function unsafeValidate<A, O>(value: any, type: t.Type<A, O>): A { | ||
if (NODE_ENV !== 'production') { | ||
export function unsafeDecode<A, O>(value: t.mixed, type: t.Type<A, O>): Either<t.Errors, A> { | ||
if (NODE_ENV !== 'production' || type.encode !== t.identity) { | ||
return type.decode(value) | ||
} else { | ||
// unsafe cast | ||
return right(value as A) | ||
} | ||
} | ||
// or... | ||
import { failure } from 'io-ts/lib/PathReporter' | ||
export function unsafeGet<A, O>(value: t.mixed, type: t.Type<A, O>): A { | ||
if (NODE_ENV !== 'production' || type.encode !== t.identity) { | ||
return type.decode(value).getOrElseL(errors => { | ||
throw new Error(failure(errors).join('\n')) | ||
}) | ||
} else { | ||
// unsafe cast | ||
return value as A | ||
} | ||
// unsafe cast | ||
return value as A | ||
} | ||
@@ -343,0 +356,0 @@ ``` |
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
113344
465
1296
4