@badrap/valita
Advanced tools
Comparing version 0.1.9 to 0.1.10
@@ -155,6 +155,2 @@ "use strict"; | ||
exports.ValitaError = ValitaError; | ||
function ok(value) { | ||
return { ok: true, value }; | ||
} | ||
exports.ok = ok; | ||
class Err { | ||
@@ -179,2 +175,6 @@ constructor(issueTree) { | ||
} | ||
function ok(value) { | ||
return { ok: true, value }; | ||
} | ||
exports.ok = ok; | ||
function err(error) { | ||
@@ -181,0 +181,0 @@ return new Err({ code: "custom_error", error }); |
@@ -155,6 +155,2 @@ "use strict"; | ||
exports.ValitaError = ValitaError; | ||
function ok(value) { | ||
return { ok: true, value }; | ||
} | ||
exports.ok = ok; | ||
class Err { | ||
@@ -179,2 +175,6 @@ constructor(issueTree) { | ||
} | ||
function ok(value) { | ||
return { ok: true, value }; | ||
} | ||
exports.ok = ok; | ||
function err(error) { | ||
@@ -181,0 +181,0 @@ return new Err({ code: "custom_error", error }); |
@@ -43,8 +43,6 @@ declare type PrettyIntersection<V> = Extract<{ | ||
} | ||
declare type Ok<T> = Readonly<{ | ||
ok: true; | ||
value: T; | ||
}>; | ||
declare function ok<T extends Literal>(value: T): Ok<T>; | ||
declare function ok<T>(value: T): Ok<T>; | ||
interface Ok<T> { | ||
readonly ok: true; | ||
readonly value: T; | ||
} | ||
declare class Err { | ||
@@ -58,3 +56,6 @@ private readonly issueTree; | ||
} | ||
declare function err<E extends CustomError>(error?: E): Err; | ||
declare function ok<T extends Literal>(value: T): Ok<T>; | ||
declare function ok<T>(value: T): Ok<T>; | ||
declare function err(error?: CustomError): Err; | ||
export type { Ok, Err }; | ||
export declare type ValitaResult<V> = Ok<V> | Err; | ||
@@ -61,0 +62,0 @@ declare type RawResult<T> = true | Readonly<{ |
{ | ||
"name": "@badrap/valita", | ||
"version": "0.1.9", | ||
"version": "0.1.10", | ||
"description": "A validation & parsing library for TypeScript", | ||
@@ -5,0 +5,0 @@ "main": "./dist/cjs/index.js", |
@@ -204,11 +204,5 @@ // This is magic that turns object intersections to nicer-looking types. | ||
type Ok<T> = Readonly<{ | ||
ok: true; | ||
value: T; | ||
}>; | ||
function ok<T extends Literal>(value: T): Ok<T>; | ||
function ok<T>(value: T): Ok<T>; | ||
function ok<T>(value: T): Ok<T> { | ||
return { ok: true, value }; | ||
interface Ok<T> { | ||
readonly ok: true; | ||
readonly value: T; | ||
} | ||
@@ -238,6 +232,13 @@ | ||
function err<E extends CustomError>(error?: E): Err { | ||
function ok<T extends Literal>(value: T): Ok<T>; | ||
function ok<T>(value: T): Ok<T>; | ||
function ok<T>(value: T): Ok<T> { | ||
return { ok: true, value }; | ||
} | ||
function err(error?: CustomError): Err { | ||
return new Err({ code: "custom_error", error }); | ||
} | ||
export type { Ok, Err }; | ||
export type ValitaResult<V> = Ok<V> | Err; | ||
@@ -244,0 +245,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
360319
6295