不要怂,就是干,撸起袖子干!

Commit e35a9bf5 by Lorhan Sohaky Committed by GitHub

fix(types): fix `ValidationErrorItem` types (#13108)

Co-authored-by: papb <papb1996@gmail.com>
1 parent 466e361e
...@@ -55,18 +55,18 @@ class ValidationError extends BaseError { ...@@ -55,18 +55,18 @@ class ValidationError extends BaseError {
*/ */
class ValidationErrorItem { class ValidationErrorItem {
/** /**
* Creates new validation error item * Creates a new ValidationError item. Instances of this class are included in the `ValidationError.errors` property.
* *
* @param {string} message An error message * @param {string} [message] An error message
* @param {string} type The type/origin of the validation error * @param {string} [type] The type/origin of the validation error
* @param {string} path The field that triggered the validation error * @param {string} [path] The field that triggered the validation error
* @param {string} value The value that generated the error * @param {string} [value] The value that generated the error
* @param {object} [inst] the DAO instance that caused the validation error * @param {Model} [instance] the DAO instance that caused the validation error
* @param {object} [validatorKey] a validation "key", used for identification * @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} [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, instance, validatorKey, fnName, fnArgs) {
/** /**
* An error message * An error message
* *
...@@ -77,21 +77,21 @@ class ValidationErrorItem { ...@@ -77,21 +77,21 @@ class ValidationErrorItem {
/** /**
* The type/origin of the validation error * The type/origin of the validation error
* *
* @type {string} * @type {string | null}
*/ */
this.type = null; this.type = null;
/** /**
* The field that triggered the validation error * The field that triggered the validation error
* *
* @type {string} * @type {string | null}
*/ */
this.path = path || null; this.path = path || null;
/** /**
* The value that generated the error * The value that generated the error
* *
* @type {string} * @type {string | null}
*/ */
this.value = value !== undefined ? value : null; this.value = value !== undefined ? value : null;
...@@ -100,28 +100,28 @@ class ValidationErrorItem { ...@@ -100,28 +100,28 @@ class ValidationErrorItem {
/** /**
* The DAO instance that caused the validation error * The DAO instance that caused the validation error
* *
* @type {Model} * @type {Model | null}
*/ */
this.instance = inst || null; this.instance = instance || null;
/** /**
* A validation "key", used for identification * A validation "key", used for identification
* *
* @type {string} * @type {string | null}
*/ */
this.validatorKey = validatorKey || 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 * 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; this.validatorName = fnName || null;
/** /**
* Parameters used with the BUILT-IN validator function, if applicable * Parameters used with the BUILT-IN validator function, if applicable
* *
* @type {string} * @type {Array}
*/ */
this.validatorArgs = fnArgs || []; this.validatorArgs = fnArgs || [];
......
import Model from "./model";
/** /**
* The Base Error all Sequelize Errors inherit from. * The Base Error all Sequelize Errors inherit from.
*/ */
...@@ -35,27 +37,51 @@ export class ValidationErrorItem { ...@@ -35,27 +37,51 @@ export class ValidationErrorItem {
/** An error message */ /** An error message */
public readonly message: string; public readonly message: string;
/** The type of the validation error */ /** The type/origin of the validation error */
public readonly type: string; public readonly type: string | null;
/** The field that triggered the validation error */ /** The field that triggered the validation error */
public readonly path: string; public readonly path: string | null;
/** The value that generated the error */ /** 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; public readonly original: Error;
/** /**
* Validation Error Item * Creates a new ValidationError item. Instances of this class are included in the `ValidationError.errors` property.
* Instances of this class are included in the `ValidationError.errors` property.
* *
* @param message An error message * @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 path The field that triggered the validation error
* @param value The value that generated the error * @param value The value that generated the error
*/ * @param instance the DAO instance that caused the validation error
constructor(message?: string, type?: string, path?: string, value?: string); * @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 { export interface CommonErrorProperties {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!