From 92ca0f084e9362e072167164c4069c89f463affb Mon Sep 17 00:00:00 2001 From: James O'Cull Date: Mon, 30 Nov 2015 14:23:24 -0500 Subject: [PATCH 1/2] Changes to Sequelize validation promise returns that provide the appropriate property definitions for validation errors --- sequelize/sequelize.d.ts | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/sequelize/sequelize.d.ts b/sequelize/sequelize.d.ts index 0a151c60f..6785989dc 100644 --- a/sequelize/sequelize.d.ts +++ b/sequelize/sequelize.d.ts @@ -2007,7 +2007,7 @@ declare module "sequelize" { /** * The Base Error all Sequelize Errors inherit from. */ - interface BaseError extends ErrorConstructor { } + interface BaseError extends Error, ErrorConstructor { } interface ValidationError extends BaseError { @@ -2026,7 +2026,10 @@ declare module "sequelize" { * @param path The path to be checked for error items */ get( path : string ) : Array; - + + /** Array of ValidationErrorItem objects describing the validation errors */ + errors : Array + } interface ValidationErrorItem extends BaseError { @@ -2041,7 +2044,19 @@ declare module "sequelize" { * @param value The value that generated the error */ new ( message : string, type : string, path : string, value : string ) : ValidationErrorItem; - + + /** An error message */ + message : string; + + /** The type of the validation error */ + type : string; + + /** The field that triggered the validation error */ + path : string; + + /** The value that generated the error */ + value : string; + } interface DatabaseError extends BaseError { @@ -2790,7 +2805,7 @@ declare module "sequelize" { * * @param options.skip An array of strings. All properties that are in this array will not be validated */ - validate( options? : { skip?: Array } ) : Promise; + validate( options? : { skip?: Array } ) : Promise; /** * This is the same as calling `set` and then calling `save`. @@ -5571,7 +5586,7 @@ declare module "sequelize" { * @param options Query Options for authentication */ authenticate( options? : QueryOptions ) : Promise; - validate( options? : QueryOptions ) : Promise; + validate( options? : QueryOptions ) : Promise; /** * Start a transaction. When using transactions, you should pass the transaction in the options argument From d1daffcdc17f3d241bb192048f2a6286ffee1be3 Mon Sep 17 00:00:00 2001 From: James O'Cull Date: Mon, 30 Nov 2015 14:31:21 -0500 Subject: [PATCH 2/2] Minor style alignment --- sequelize/sequelize.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sequelize/sequelize.d.ts b/sequelize/sequelize.d.ts index 6785989dc..9b5e935bf 100644 --- a/sequelize/sequelize.d.ts +++ b/sequelize/sequelize.d.ts @@ -1994,7 +1994,7 @@ declare module "sequelize" { INITIALLY_IMMEDIATE: DeferrableInitiallyImmediate; NOT: DeferrableNot; SET_DEFERRED: DeferrableSetDeferred; - SET_IMMEDIATE: DeferrableSetImmediate + SET_IMMEDIATE: DeferrableSetImmediate; } // @@ -2028,7 +2028,7 @@ declare module "sequelize" { get( path : string ) : Array; /** Array of ValidationErrorItem objects describing the validation errors */ - errors : Array + errors : Array; }