Changes to Sequelize validation promise returns that provide the appropriate property definitions for validation errors

This commit is contained in:
James O'Cull
2015-11-30 14:23:24 -05:00
parent fb2b3b1e06
commit 92ca0f084e
+20 -5
View File
@@ -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<ValidationErrorItem>;
/** Array of ValidationErrorItem objects describing the validation errors */
errors : Array<ValidationErrorItem>
}
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<string> } ) : Promise<void>;
validate( options? : { skip?: Array<string> } ) : Promise<ValidationError>;
/**
* 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<void>;
validate( options? : QueryOptions ) : Promise<void>;
validate( options? : QueryOptions ) : Promise<ValidationError>;
/**
* Start a transaction. When using transactions, you should pass the transaction in the options argument