Comparing version 0.2.3 to 0.3.0
@@ -15,2 +15,9 @@ # Changelog | ||
# 0.3.0 | ||
This is a breaking change *only* if you are using fp-ts APIs | ||
- **Breaking Change** | ||
- upgrade to latest fp-ts v0.2 (@gcanti) | ||
# 0.2.3 | ||
@@ -17,0 +24,0 @@ |
{ | ||
"name": "io-ts", | ||
"version": "0.2.3", | ||
"version": "0.3.0", | ||
"description": "TypeScript compatible runtime type system for IO validation", | ||
@@ -16,3 +16,4 @@ "files": [ | ||
"test": "npm run typings-checker && npm run mocha", | ||
"build": "rm -rf lib/* && rm -rf lib-jsnext/* && tsc && tsc -m es6 --outDir lib-jsnext" | ||
"clean": "rm -rf lib/* && rm -rf lib-jsnext/*", | ||
"build": "npm run clean && tsc && tsc -m es6 --outDir lib-jsnext" | ||
}, | ||
@@ -30,3 +31,3 @@ "repository": { | ||
"dependencies": { | ||
"fp-ts": "^0.1.1" | ||
"fp-ts": "^0.2.0" | ||
}, | ||
@@ -33,0 +34,0 @@ "devDependencies": { |
@@ -180,7 +180,6 @@ # The idea | ||
import * as t from 'io-ts' | ||
import { pathReporterFailure } from 'io-ts/lib/reporters/default' | ||
// return a Date from an ISO string | ||
const ISODate = new t.Type<Date>( | ||
'ISODate', | ||
// returns a Date from an ISO string | ||
const DateFromString = new t.Type<Date>( | ||
'DateFromString', | ||
(v, c) => t.string.validate(v, c).chain(s => { | ||
@@ -193,8 +192,12 @@ const d = new Date(s) | ||
const s = new Date(1973, 10, 30).toISOString() | ||
t.validate(s, ISODate).fold(pathReporterFailure, x => [String(x)]) | ||
// => [ 'Fri Nov 30 1973 00:00:00 GMT+0100 (CET)' ] | ||
t.validate('foo', ISODate).fold(pathReporterFailure, x => [String(x)]) | ||
// => [ 'Invalid value "foo" supplied to : ISODate' ] | ||
t.validate(s, DateFromString) | ||
// => Right(Date(..)) | ||
t.validate('foo', DateFromString) | ||
// => Left( 'Invalid value "foo" supplied to : DateFromString' ) | ||
``` | ||
Note that you can **deserializing** while validating. | ||
# Custom combinators | ||
@@ -201,0 +204,0 @@ |
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
184693
294
+ Addedfp-ts@0.2.9(transitive)
+ Addedrxjs@5.5.12(transitive)
+ Addedsymbol-observable@1.0.1(transitive)
- Removedfp-ts@0.1.1(transitive)
Updatedfp-ts@^0.2.0