Socket
Socket
Sign inDemoInstall

io-ts

Package Overview
Dependencies
Maintainers
1
Versions
120
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

io-ts - npm Package Compare versions

Comparing version 0.2.3 to 0.3.0

7

CHANGELOG.md

@@ -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 @@

7

package.json
{
"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 @@

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