io-ts-fuzzy
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -37,3 +37,3 @@ "use strict"; | ||
var t = require("io-ts"); | ||
exports.fallback = function (type, factory) { return new t.Type("fuzzy.optional<" + type.name + ">", function (it) { return type.is(it); }, function (input, context) { | ||
exports.fallback = function (type, factory) { return new t.Type("fuzzy.fallback<" + type.name + ">", function (it) { return type.is(it); }, function (input, context) { | ||
if (input === null || input === undefined || input === 'null') { | ||
@@ -40,0 +40,0 @@ return t.success(factory()); |
export * from './boolean'; | ||
export * from './fallback'; | ||
export * from './fallbackInput'; | ||
export * from './float'; | ||
@@ -4,0 +5,0 @@ export * from './integer'; |
@@ -15,2 +15,3 @@ "use strict"; | ||
__exportStar(require("./fallback"), exports); | ||
__exportStar(require("./fallbackInput"), exports); | ||
__exportStar(require("./float"), exports); | ||
@@ -17,0 +18,0 @@ __exportStar(require("./integer"), exports); |
@@ -5,3 +5,3 @@ { | ||
"license": "MIT", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "A collection of io-ts codecs for fuzzy decoding untyped configs and similar things", | ||
@@ -8,0 +8,0 @@ "main": "lib/index.js", |
@@ -6,3 +6,3 @@ import { isLeft, left } from 'fp-ts/lib/Either' | ||
export const fallback = <T>(type: t.Type<T>, factory: (() => T)) => new t.Type<T>( | ||
`fuzzy.optional<${type.name}>`, | ||
`fuzzy.fallback<${type.name}>`, | ||
(it): it is T => type.is(it), | ||
@@ -9,0 +9,0 @@ (input, context) => { |
export * from './boolean' | ||
export * from './fallback' | ||
export * from './fallbackInput' | ||
export * from './float' | ||
@@ -4,0 +5,0 @@ export * from './integer' |
@@ -23,5 +23,5 @@ import { fallback } from '../src/fallback' | ||
assertFailure(myType, 15.13, [ | ||
'Invalid value 15.13 supplied to : fuzzy.optional<fuzzy.integer>/: fuzzy.integer', | ||
'Invalid value 15.13 supplied to : fuzzy.fallback<fuzzy.integer>/: fuzzy.integer', | ||
]) | ||
}) | ||
}) |
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
55344
66
1545