Comparing version 0.7.3 to 0.7.4
@@ -8,3 +8,3 @@ import { Exception } from 'typesafe-exception'; | ||
status: number; | ||
constructor(errors: DecodeError[]); | ||
constructor(schema: Schema<unknown>, errors: DecodeError[]); | ||
} | ||
@@ -11,0 +11,0 @@ export interface DecodeError { |
@@ -8,4 +8,5 @@ "use strict"; | ||
class ValidationError extends typesafe_exception_1.Exception { | ||
constructor(errors) { | ||
super('Validation failed', { errors }); | ||
constructor(schema, errors) { | ||
var _a; | ||
super(`Validation failed (${(_a = schema.id) !== null && _a !== void 0 ? _a : schema.type}}`, { errors }); | ||
this.status = 400; | ||
@@ -12,0 +13,0 @@ } |
@@ -18,3 +18,3 @@ "use strict"; | ||
if (this.options.throw && this.errors.length > 0) { | ||
throw new decoder_1.ValidationError(this.errors); | ||
throw new decoder_1.ValidationError(this.decoder.schema, this.errors); | ||
} | ||
@@ -21,0 +21,0 @@ return res; |
@@ -14,2 +14,3 @@ export declare type Schema<T> = unknown extends T ? UnknownSchema : ((StrictTypeSchema<T> | AnySchema | RefSchema) & (undefined extends T ? { | ||
nullable?: true; | ||
id?: string; | ||
}; | ||
@@ -16,0 +17,0 @@ export declare type BaseSchema<T> = { |
{ | ||
"name": "airtight", | ||
"version": "0.7.3", | ||
"version": "0.7.4", | ||
"description": "Tight subset of JSON schema", | ||
@@ -5,0 +5,0 @@ "main": "out/main/index.js", |
16513
440