Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
public
/
sequelize
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
不要怂,就是干,撸起袖子干!
Commit e35a9bf5
authored
Mar 21, 2021
by
Lorhan Sohaky
Committed by
GitHub
Mar 21, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(types): fix `ValidationErrorItem` types (#13108)
Co-authored-by: papb <papb1996@gmail.com>
1 parent
466e361e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
27 deletions
lib/errors/validation-error.js
types/lib/errors.d.ts
lib/errors/validation-error.js
View file @
e35a9bf
...
...
@@ -55,18 +55,18 @@ class ValidationError extends BaseError {
*/
class
ValidationErrorItem
{
/**
* Creates
new validation error item
*
* @param {string}
message
An error message
* @param {string}
type
The type/origin of the validation error
* @param {string}
path
The field that triggered the validation error
* @param {string}
value
The value that generated the error
* @param {
object} [inst
] the DAO instance that caused the validation error
* @param {
object
} [validatorKey] a validation "key", used for identification
* Creates
a new ValidationError item. Instances of this class are included in the `ValidationError.errors` property.
*
* @param {string}
[message]
An error message
* @param {string}
[type]
The type/origin of the validation error
* @param {string}
[path]
The field that triggered the validation error
* @param {string}
[value]
The value that generated the error
* @param {
Model} [instance
] the DAO instance that caused the validation error
* @param {
string
} [validatorKey] a validation "key", used for identification
* @param {string} [fnName] property name of the BUILT-IN validator function that caused the validation error (e.g. "in" or "len"), if applicable
* @param {
string
} [fnArgs] parameters used with the BUILT-IN validator function, if applicable
* @param {
Array
} [fnArgs] parameters used with the BUILT-IN validator function, if applicable
*/
constructor
(
message
,
type
,
path
,
value
,
inst
,
validatorKey
,
fnName
,
fnArgs
)
{
constructor
(
message
,
type
,
path
,
value
,
inst
ance
,
validatorKey
,
fnName
,
fnArgs
)
{
/**
* An error message
*
...
...
@@ -77,21 +77,21 @@ class ValidationErrorItem {
/**
* The type/origin of the validation error
*
* @type {string}
* @type {string
| null
}
*/
this
.
type
=
null
;
/**
* The field that triggered the validation error
*
* @type {string}
* @type {string
| null
}
*/
this
.
path
=
path
||
null
;
/**
* The value that generated the error
*
* @type {string}
* @type {string
| null
}
*/
this
.
value
=
value
!==
undefined
?
value
:
null
;
...
...
@@ -100,28 +100,28 @@ class ValidationErrorItem {
/**
* The DAO instance that caused the validation error
*
* @type {Model}
* @type {Model
| null
}
*/
this
.
instance
=
inst
||
null
;
this
.
instance
=
inst
ance
||
null
;
/**
* A validation "key", used for identification
*
* @type {string}
* @type {string
| null
}
*/
this
.
validatorKey
=
validatorKey
||
null
;
/**
* Property name of the BUILT-IN validator function that caused the validation error (e.g. "in" or "len"), if applicable
*
* @type {string}
* @type {string
| null
}
*/
this
.
validatorName
=
fnName
||
null
;
/**
* Parameters used with the BUILT-IN validator function, if applicable
*
* @type {
string
}
* @type {
Array
}
*/
this
.
validatorArgs
=
fnArgs
||
[];
...
...
types/lib/errors.d.ts
View file @
e35a9bf
import
Model
from
"./model"
;
/**
* The Base Error all Sequelize Errors inherit from.
*/
...
...
@@ -35,27 +37,51 @@ export class ValidationErrorItem {
/** An error message */
public
readonly
message
:
string
;
/** The type of the validation error */
public
readonly
type
:
string
;
/** The type
/origin
of the validation error */
public
readonly
type
:
string
|
null
;
/** The field that triggered the validation error */
public
readonly
path
:
string
;
public
readonly
path
:
string
|
null
;
/** The value that generated the error */
public
readonly
value
:
string
;
public
readonly
value
:
string
|
null
;
/** The DAO instance that caused the validation error */
public
readonly
instance
:
Model
|
null
;
/** A validation "key", used for identification */
public
readonly
validatorKey
:
string
|
null
;
/** Property name of the BUILT-IN validator function that caused the validation error (e.g. "in" or "len"), if applicable */
public
readonly
validatorName
:
string
|
null
;
/** Parameters used with the BUILT-IN validator function, if applicable */
public
readonly
validatorArgs
:
unknown
[];
public
readonly
original
:
Error
;
/**
* Validation Error Item
* Instances of this class are included in the `ValidationError.errors` property.
* Creates a new ValidationError item. Instances of this class are included in the `ValidationError.errors` property.
*
* @param message An error message
* @param type The type of the validation error
* @param type The type
/origin
of the validation error
* @param path The field that triggered the validation error
* @param value The value that generated the error
*/
constructor
(
message
?:
string
,
type
?:
string
,
path
?:
string
,
value
?:
string
);
* @param instance the DAO instance that caused the validation error
* @param validatorKey a validation "key", used for identification
* @param fnName property name of the BUILT-IN validator function that caused the validation error (e.g. "in" or "len"), if applicable
* @param fnArgs parameters used with the BUILT-IN validator function, if applicable
*/
constructor
(
message
?:
string
,
type
?:
string
,
path
?:
string
,
value
?:
string
,
instance
?:
object
,
validatorKey
?:
string
,
fnName
?:
string
,
fnArgs
?:
unknown
[]
);
}
export
interface
CommonErrorProperties
{
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment